Deprecated: Hook custom_css_loaded is deprecated since version jetpack-13.5! Use WordPress Custom CSS instead. Jetpack no longer supports Custom CSS. Read the documentation to learn how to apply custom styles to your site: in /var/www/html/wp-includes/functions.php on line 6078 Cloudflare DDNS configuration for Unifi USG – D Khaz Skip to content

Cloudflare DDNS configuration for Unifi USG

I’ve recently made the switch to using Cloudflare as my DDNS provider.  Unfortunately, Ubiquiti has not done a good job of expanding and updating its DDNS providers in the Unifi Controller.

Update USG ddclient

The USG firmware is using an older version of the ddclient which is no longer supported by cloudflare.  So, in order to get it to connect, you need to upgrade to the newer version.  Luckily, @troyfontaine has done all the heavy lifting and shared it with the worldGo buy him a beer.  You can perform the individual steps as shown in the script or execute the thing with curl.

Testing the configuration

Before permanently making this configuration, I wanted to test my settings.  Below are the configuration commands used to enable this by SSH’ing into your USG. The zone should match the zone name in CF and the password is the API Zone ID that’s listed on the overview page.

If you are unfamiliar how to do this, you can learn more from Ubiquiti’s instructions for EdgeRouters which use the same tools.  I like to use the commit-confirm 5 option in case I’ve messed up any entries through the CLI.  Keep in mind, this configuration will not survive re-provisioning of the USG from the controller as the controller does not have these settings.

Permanent Configuration

After having my settings on for a week, I decided to configure these settings.  You will need to follow the USG Advanced Configuration process as outlined by Ubiquiti.

Published inHomeLABNetworking


  1. Ant Ant

    So this more/less works from the configure interface (i had to use custom-cloudflare as the service name and had to use my global API key as opposed to the DNS Zone Key). However, it doesnt seem to work with the config.gateway.json file to make it permanent. The settings take and are identical, but i never seems to update. Any thoughts?

  2. DK DK

    So it’s working when you ssh in and commit; save but not through the controller?

    Whats your status output: update dns dynamic interface eth2 && sleep 20 && show dns dynamic status

  3. Ant Ant

    Well my WAN is on eth0, so thats the interface I use. But after forcing the update and running a status (with the sleep 20 inbetween) I get:

    interface : eth0
    ip address :
    host-name :mydomain.tld
    last update : Wed Dec 31 19:00:00 1969
    update-status: noconnect

    It’s really strange that it works with direct config and not via the json config. I’ve triple checked the JSON, permissions/ownership of the JSON file, and compared show configuration between it being applied directly and from my Cloud Key and they are identical. It’s baffling.

  4. DK DK

    Yea, that is baffling. Does it provision fine with the JSON file’s config? Have you tried monitoring the logs when you provision it to see if anything weird pops up?

  5. Ant Ant

    I have, I’ve run show log tail, which has the entires about the ip='' and skipping update from to [my WAN ip address]. But other than the skip thats normal from what I’ve read. I also tried doing a /usr/sbin/ddclient -query and didn’t get anything useful there either. I did find that I had to upgrade ddclient to 3.9.x to get even the confure commands to work, but that is still in place. At this point my API access for Namecheap has gone through and I think I’m just go that route.

  6. DK DK

    Very odd. You could try running that curl script again and seeing if it helps anything.
    Maybe try ubnt forums as this is above my pay grade.

  7. Jon Irish Jon Irish

    I went ahead and tried this today. I get as far as trying to run the “set service dns dynamic interface” commands. On my UGS 3P, I don’t have “set service” as an option. If I do a “set ?” the only options I get are “date” and “system”. Without these set, i get errors when running “update dns dynamic interface eth2 && sleep 20 && show dns dynamic status” about ddns not being configured.


  8. DK DK

    Are you in the configure mode?

  9. Jon Irish Jon Irish

    Wow, I can’t believe that I forgot to go into config mode (DUH). It’s been a long day 😉 So, after going into config mode, the set statements were accepted w/o any errors, but the update was not successful:
    interface : eth0
    ip address :
    host-name :
    last update : Wed Dec 31 18:00:00 1969
    update-status: noconnect

    Are there any log files available that might explain where my issue is?


  10. Anonymous Anonymous

    Great write up. Along with a couple other guides online, I was able to get Cloudflare DynDNS configured via JSON file on my UniFi.
    However, it isn’t auto-updating. Works fine when I run the command to update, but doesn’t seem to run again unless I do it manually.
    Is there a way to configure ddclient to run on a schedule that I’ve missed somewhere?

  11. Anonymous Anonymous

    Will this automatically update weekly or does a crown job need to be configured?

  12. DK DK

    No it’s part of the DDNS service

Leave a Reply

Your email address will not be published. Required fields are marked *