Ubiquiti Unifi DNS Fix
We host our Unifi Controller behind our primary Unifi network without about 85 other locations that connect back to it. A problem that we were seeing was the USG for our primary site would constantly show in a state of “Adopting” even though the devices were already adopted and received their configurations.
This is caused by the USG searching for my controller via DNS on its external IP address which it can’t reach. Instead we’ll need to trick the USG to find the DNS name of the controller on the local IP address of the network.
There are 2 ways to fix this. One is a temporary fix that works as long as the device doesn’t update or a config changes and the other is a more permanent fix.
Temporary Fix
The temporary fix involves SSH’ing into the USG and entering a static host map.
SSH into the USG with your favorite SSH client. On Windows, I tend to use Windows Terminal. Once connected run the following commands:
Enter Configuration Mode
configure
Set the static-host-mapping to your hostname and internal IP address. In my example its unifi.domain.com that should point to 192.168.1.10
set system static-host-mapping host-name unifi.domain.com inet 192.168.1.10
Commit the changes
commit
Save the commit
save
and then Exit from Configuration Mode
exit
Next, set he Inform URL before ending your SSH session
set-inform http://unifi.domain.com:8080/inform
Note: The fix above will be lost after a reboot or configuration change and should only be used as a temp fix.
Permanent Fix
For a more permanent fix, we’ll need to create a config.gateway.json file with the information and save it to our Unifi Controller. Our controller is hosted on Ubuntu 20.04, so the instructions going forward will utilize Linux commands and file locations.
The first step is to get the Site ID. This can be obtained from the address bar in your browser when you visit the site in your Unifi Controller. The Site ID is located between /site/ and /dashboard in the example below.
SSH into your Unifi Controller and run the following commands to create and edit the config.gateway.json file located in the /var/lib/unifi/sites/[site_id] directory:
sudo touch /var/lib/unifi/sites/ncjodgcu/config.gateway.json sudo nano /var/lib/unifi/sites/ncjodgcu/config.gateway.json
I won’t get into the JSON file itself, but instead you can download a copy below and then copy and paste that into your terminal. For more info on how to structure a JSON file can be found here.
The file looks like the image and all you will need to do is change the host-name, alias, and inet address to match your network.
Once the contents have been pasted, save and exit the file. Restart the Unifi Controller and the USG should begin provisioning the new changes.
sudo /etc/init.d/unifi restart
That’s it! Once provisioned, you USG and other devices should show Connected instead of Adopting.
Download the JSON file (zipped)