Skip to content

Dynamic DNS (DDNS) service implementation for Cloudflare Workers.

License

Notifications You must be signed in to change notification settings

hectorm/cloudflare-worker-ddns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare Dynamic DNS worker

Dynamic DNS service implementation for Cloudflare Workers.

Deployment instructions

  1. Create the desired DNS record(s) in Cloudflare.
  2. Deploy the worker.
  3. 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 the Zone.DNS:Edit permission.
  4. Test the worker with the following command (optional):
    curl --verbose --user "<username>" "https://<worker-name>.<subdomain>.workers.dev/nic/update?hostname=<hostname>&myip=<ip>"

Setup with UniFi OS

Note

Tested on UDM-Pro-Max with UniFi OS 4.0.21 (Network 8.6.9 - inadyn 2.12.0).

  1. Log in to the UniFi OS Controller web interface.
  2. Navigate to Settings -> Internet -> WAN interface -> Advanced -> Dynamic DNS.
  3. Set the following options:
    • Service: custom.
    • Hostname: the DNS record to update, must be in the DDNS_RECORD_ALLOWLIST if set.
    • Username: same as the DDNS_USERNAME worker variable.
    • Password: same as the DDNS_PASSWORD worker variable.
    • Server: <worker-name>.<subdomain>.workers.dev/nic/update?hostname=%h&myip=%i, do not include the https:// scheme (it is added automatically), %h and %i are placeholders that UniFi OS automatically fills in.
  4. 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

Setup with EdgeOS

Note

Tested on EdgeRouter ER-x with EdgeOS v3.0.0-rc.9

  1. Log in to the EdgeOS web interface.
  2. Follow the steps on the Help Center to configure DDNS
  3. 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
  4. Test the configuration by manually triggering a DDNS update (optional):
    update dns dynamic interface eth0

About

Dynamic DNS (DDNS) service implementation for Cloudflare Workers.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 2

  •  
  •