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.
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.
On the CloudKey, the config file is located at /usr/lib/unifi/data/sites/default/config.gateway.json
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.
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.
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
If the configuration doesn't seem to be applying-you may need to reboot your Controller/CloudKey.
I don't have a folder / site / pattern on my Cloudkey as you can see below ... how should I proceed?
root@UniFi-CloudKey:/usr/lib/unifi/data# ls
backup/ firmware.json model_lifecycles.json system.properties tmp/
db/ keystore@ system.configured system.properties.bk webrtc/
root@UniFi-CloudKey:/usr/lib/unifi/data#