Dynamic DNS service implementation for Cloudflare Workers.
- Create the desired DNS record(s) in Cloudflare.
- Deploy the worker.
- Set the following variables and secrets in the worker dashboard:
DDNS_USERNAME: a username for the Dynamic DNS service.DDNS_PASSWORD: a password for the Dynamic DNS service.DDNS_RECORD_ALLOWLIST: a comma-separated list of DNS record(s) that the Dynamic DNS service is allowed to update (optional).CF_API_TOKEN: a Cloudflare API token with theZone.DNS:Editpermission.
- Test the worker with the following command (optional):
curl --verbose --user "<username>" "https://<worker-name>.<subdomain>.workers.dev/nic/update?hostname=<hostname>&myip=<ip>"
Note
Tested on UDM-Pro-Max with UniFi OS 4.0.21 (Network 8.6.9 - inadyn 2.12.0).
- Log in to the UniFi OS Controller web interface.
- Navigate to
Settings->Internet-> WAN interface ->Advanced->Dynamic DNS. - Set the following options:
Service:custom.Hostname: the DNS record to update, must be in theDDNS_RECORD_ALLOWLISTif set.Username: same as theDDNS_USERNAMEworker variable.Password: same as theDDNS_PASSWORDworker variable.Server:<worker-name>.<subdomain>.workers.dev/nic/update?hostname=%h&myip=%i, do not include thehttps://scheme (it is added automatically),%hand%iare placeholders that UniFi OS automatically fills in.
- Test the configuration by running the following command in the UniFi OS shell (optional):
inadyn --foreground --once --force --loglevel debug --config /run/ddns-ppp0-inadyn.conf
Note
Tested on EdgeRouter ER-x with EdgeOS v3.0.0-rc.9
- Log in to the EdgeOS web interface.
- Follow the steps on the Help Center to configure DDNS
- Set the settings accordingly
# the DNS record to update, must be in the `DDNS_RECORD_ALLOWLIST` if set. set service dns dynamic interface eth0 service cloudflare-worker host-name <host> # same as the DDNS_USERNAME worker variable set service dns dynamic interface eth0 service cloudflare-worker login <username> # same as the DDNS_PASSWORD worker variable. set service dns dynamic interface eth0 service cloudflare-worker password <password> # /nic/update?hostname=%h&myip=%i is automatically populated in EdgeOS set service dns dynamic interface eth0 service cloudflare-worker server <worker-name>.<subdomain>.workers.dev # setting protocol to "custom" renders an error set service dns dynamic interface eth0 service cloudflare-worker protocol dyndns2
- Test the configuration by manually triggering a DDNS update (optional):
update dns dynamic interface eth0