A Cloudflare Worker script that enables UniFi devices (e.g., UDM-Pro, USG) to dynamically update DNS A/AAAA records on Cloudflare.
Note: This is a fork of willswire/unifi-ddns. Check out the original project for updates and community support.
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.devroute.
- Clone this repository:
git clone https://github.com/ry-ops/unifi-ddns.git cd unifi-ddns - Install Wrangler CLI.
- Run:
npm i wrangler login wrangler deploy
- Note the
*.workers.devroute.
- 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.comorexample.com - Username: Cloudflare Account Email Address (e.g.,
you@example.com) - Password: Cloudflare User API Token (not an Account API Token)
- Server:
<worker-name>.<worker-subdomain>.workers.dev/update?ip=%i&hostname=%h(Omithttps://)
- Service:
- Check the DDNS status in UniFi (Settings > Internet > WAN)
- Verify the DNS record in Cloudflare matches your public IP
- Monitor the worker in Cloudflare Dashboard (Workers & Pages > your worker > Logs)
Using this script with various Ubiquiti devices and different UniFi software versions can introduce unique challenges. If you encounter issues:
- Check that you omitted
https://from the Server field - Verify your API token has correct permissions (Edit zone DNS)
- Ensure the hostname exactly matches what you want in Cloudflare
- Confirm
%iand%hplaceholders are in the Server URL
For more help, refer to the original project's FAQ or discussions.
This project maintains the same license as the original willswire/unifi-ddns project.
Original project by willswire. This fork is maintained by ry-ops for personal use.
