The following tools are only needed if you are using something like the UniFi Cloud Key

  • A SSH Client (for example Putty if you are using Windows)
  • A FTP Client (for example FileZilla if you are using Windows)

Getting Started

First you need to get a Global API Key from Cloudflare. For that you need to open this page and click on "Change" first to regenerate your API Key and afterwards on "View"


Now you need to add a DNS A record to your domain that is pointing to


After creating your DNS record you need to create a config.gateway.json file with the following content:

  "service": {
    "dns": {
      "dynamic": {
        "interface": {
          "<The network interface that is facing the internt. For me it's eth0, but could be different for you>": {
            "service": {
              "cloudflare": {
                "host-name": [
                  "<The name of the previous created A record. for example>"
                "login": "<Your Cloudflare E-Mail address>",
                "options": [
                  "zone=<Your domain. for example>"
                "password": "<Your Cloudflare API Key>",
                "protocol": "cloudflare",
                "server": ""
            "web": "dyndns"

You need to replace the placeholders with your own data. To get the interface that you are using you need to SSH into your router and enter ip addr to see the network interfaces of your router.
Now you ned to copy the file to the <unifi_base>data/sites/default directory. The <unifi_base> path is different for each platform:

  • UniFi Cloud Key: /usr/lib/unifi
  • Debian/Ubuntu Linux: /usr/lib/unifi
  • Windows: %userprofile%/Ubiquiti UniFi.
  • macOS: ~/Library/Application Support/UniFi


Aftwards you need to update the old version of ddclient on your Unifi router:

  1. First you need to connect to the router via SSH. If you don't know how to connect to your router via SSH take a look at this article from Ubiquiti
  2. Now you need to make a copy of your existing ddclient:
sudo cp usr/sbin/ddclient /usr/sbin/ddclient.bak
  1. The only thing left to do is to update ddclient to the new version provided by Ubiquti:
curl -O ttps:// && sudo chmod +x ddclient && sudo mv ddclient /usr/sbin/ddclient

This is only a temporary workaround. You are going to need to upgrade the ddclient everytime you upgrade the firmware of your router.

The final step is to force provision your router with the new config. To force provision your router you first need to go to the clients list in your UniFi Network Controller


and open the property panel with a click on your router. Now you need to open the settings of your router in the opened side panel


go to the Manage Device section and click on Provision


Checking the result

To check if your dynamic DNS is working open a command line and enter nslookup <DNS A Record>> to check the IP address that is being reported to Cloudflare by the Ubiquti router


> nslookup <DNS A Record>

Nicht autorisierende Antwort:


If the external IP address does not match your external IP you need to SSH into your router again and enter update dns dynamic interface eth0 to force an update of your dynamic dns record and show dns dynamic status after waiting a few seconds to see the current status of your dynamic dns:


> update dns dynamic interface eth0
> show dns dynamic status
interface    : eth0
ip address   : XXX.XXX.XXX.XXX
host-name    :
last update  : Fri Jul  1 12:00:00 2020
update-status: good