A Cloudflare Worker script that enables UniFi devices (e.g., UDM-Pro, USG) to dynamically update DNS A/AAAA records on Cloudflare.
UniFi devices do not natively support Cloudflare as a DDNS provider. This script bridges that gap, allowing your UniFi device to keep your DNS records updated with your public IP address.
- Click the button above.
- Complete the deployment.
- Note the
*.workers.dev
route.
- Clone this repository.
- Install Wrangler CLI.
- Run:
wrangler login wrangler deploy
- Note the
*.workers.dev
route.
- Go to the Cloudflare Dashboard.
- Navigate to Profile > API Tokens
- Create a token using the Edit zone DNS template.
- Scope the token to one specific zone.
- Save the token securely.
- Log in to your UniFi OS Controller.
- Go to Settings > Internet > WAN > Dynamic DNS.
- Create New Dynamic DNS with the following information:
- Service:
custom
- Hostname:
subdomain.example.com
orexample.com
- Username: Cloudflare Account Email Address (e.g.,
[email protected]
) - Password: Cloudflare User API Token (not an Account API Token)
- Server:
<worker-name>.<worker-subdomain>.workers.dev/update?ip=%i&hostname=%h
(Omithttps://
)
- Service:
- SSH into your UDM-Pro.
- Run:
ps aux | grep inadyn inadyn -n -1 --force -f /run/ddns-eth4-inadyn.conf
- Check
/var/log/messages
for errors.
- SSH into your USG.
- Run:
sudo ddclient -daemon=0 -verbose -noquiet -debug -file /etc/ddclient/ddclient_eth0.conf
- Look for
SUCCESS
in the output.
- Updates occur approximately every two minutes. You can tail the worker logs to validate updates from your UniFi device.
- For subdomains (
sub.example.com
), manually create an A record in Cloudflare first. - Remove
https://
from the Server field. - Wildcard domains: Use
*.example.com
in the Hostname field. - UniFi OS may require recreating DDNS entries instead of editing them.