Skip to content

Instantly share code, notes, and snippets.

@tsopokis
Forked from troyfontaine/README.md
Created November 10, 2022 20:06
Show Gist options
  • Save tsopokis/98849d878c1bb8d53667a874f84577e0 to your computer and use it in GitHub Desktop.
Save tsopokis/98849d878c1bb8d53667a874f84577e0 to your computer and use it in GitHub Desktop.
Ubiquiti USG config.gateway.json Syntax

Ubiquiti USG Advanced Configuration

Overview

Integrated DNS Overview

When using a USG with Ubiquiti's Unifi Controller software (version 5.6 and earlier), the functionality of integrating the hostnames of clients (when they request a DHCP lease) into local DNS does not appear to work as you would find with Consumer grade routers. To work around this limitation, we can add static host mappings to a configuration file that will be provisioned to the USG when either a configuration change is made or we force provisioning to the USG itself.

Non-GUI Supported Dynamic DNS Providers

I've added in the necessary syntax for adding Cloudflare DDNS to the USG for VPN/Services setup courtesy of this post by britannic on the Ubiquiti Forums.

Configuration File

On the CloudKey, the config file is located at /usr/lib/unifi/data/sites/default/config.gateway.json

Cloudflare DNS

You MUST pre-create the A Record for the hostname you wish to use for the USG. Once the record is created, API calls can successfully modify the record.

Later Releases

Override

The configuration in this file is overridden in the Unifi Controller software after version 5.6 by DHCP reservations (which appears to provide similar functionality to consumer-grade routers in that you no longer need to provide a configuration and hostnames are captured when they request a DHCP lease). It appears to be simply ignored.

Static IPs

In Unifi Controller software after 5.6, setting a static IP in the configuration when using a USG and after a client has already received their DHCP assigned address, to update the built-in DNS you must release and renew the client's IP from the client to update the DNS configuration

Troubleshooting

If the configuration doesn't seem to be applying-you may need to reboot your Controller/CloudKey.

{
"service": {
"dns": {
"dynamic": {
"interface": {
"eth0": {
"service": {
"custom-cloudflare": {
"host-name": [
"host.mydomain.tld"
],
"login": "[email protected]",
"options": [
"zone=mydomain.tld"
],
"password": "MYAPIKEYGOESHERE",
"protocol": "cloudflare",
"server": "www.cloudflare.com"
}
}
}
}
}
}
},
"system": {
"static-host-mapping": {
"host-name": {
"mynas.mynet.mydomain.com": {
"alias": [
"mynas"
],
"inet": [
"192.168.1.99"
]
},
"unifi.mynet.mydomain.com": {
"alias": [
"unifi"
],
"inet": [
"192.168.1.30"
]
}
}
}
}
}
{
"system": {
"static-host-mapping": {
"host-name": {
"mynas.mynet.mydomain.com": {
"alias": [
"mynas"
],
"inet": [
"192.168.1.99"
]
},
"unifi.mynet.mydomain.com": {
"alias": [
"unifi"
],
"inet": [
"192.168.1.30"
]
}
}
}
}
}
@tsopokis
Copy link
Author

In order to have these folders you have to upload a floorplan at least one time so the folder structures will be created. Until now (version 7.2.94 of the controller), this option is only available in the "Legacy Interface". In order to revert to "Legacy Interface" go to Settings -> System -> Legacy Interface and enable it.

Then go to Map and from the top left dropdown Topology, change it to floor plan. Then add a floor plan and save it. Now the directory structure should be ok and you could delete the floor plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment