UnFi OS
has in-built support for DDNS for WAN connections but Cloudflare
is not supported OOTB. This Cloudflare Worker is designed to provide the intermediary support required to allow UnFi OS
to update Cloudflare using the OOTB options.
This Cloudflare Worker accepts parameters specified under Settings > Internet > WAN > Dynamic DNS > custom
which UniFi OS
uses to call whenever an IP change is detected. The Cloudflare Worker then calls Cloudflare DNS API to update the specified DNS A record with the new IP address.
Based on the implementation from - https://github.com/willswire/unifi-ddns - Thanks!
Updated 22-08-2024 - Added Telegram Notifications
You need to be using Cloudflare for you domain which means using Cloudflare nameservers and managing your domains DNS within Cloudflare.
- Deploy the Worker using the Cloudflare dashboard
- In the Cloudflare Workers dashboard - note the
\*.workers.dev
URL - Create a Cloudflare API token to update DNS records -
https://dash.cloudflare.com/profile/api-tokens
- Click
Create token
, selectCreate custom token
- Choose
Zone > DNS > Edit
for permissions, and include your zone underZone Resources
- Copy the API Key which will be used later
- Clone or download this project
- Ensure you have
Cloudflare [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/)
installed - Log in with Cloudlfare Wrangler and run
wrangler deploy
- Note the
\*.workers.dev
URL after creation - Create an API token mentioned above
The latest update includes support for Telegram notifications. Two environment variables are required for this to work.
telegramBotToken
telegramChatId
These need to be created as environment variables on the Cloudflare Worker.
https://unifi.ui.com/
- Click
Settings > Internet > WAN > Dynamic DNS
- Click
Create New Dynamic DNS
and enter the following parameters -Service
: Choosecustom
Hostname
: DNS record to update insubdomain.domain.com
format to update (example -subdomain.domain.com
ordomain.com
for root)Username
: Domain name (exampledomain.com
)Password
: Cloudflare API Token as created aboveServer
: Cloudflare Worker URL<worker-name>.<worker-subdomain>.workers.dev/update?ip=%i&hostname=%h
Test the setup and force a manual update on a UDM-Pro -
- SSH into your the UDM-Pro device
- Run
ps aux | grep inadyn
- Note the configuration file path which looks similar to
/run/ddns-eth4-inadyn.conf
- Run
inadyn -n -1 --force -f <config-path>
(example -inadyn -n -1 --force -f /run/ddns-eth4-inadyn.conf
) - Check the response and Cloudlare DNS or Cloudflare Worker logs
/var/log/messages
can also be checked error messages
- For subdomains (example -
subdomain.domain.com
) - create an A record manually in Cloudflare DNS first. - For errors with hostname resolution (
inadyn[2173778]: Failed resolving hostname https: Name or service not known
), removehttps://
from theServer
field - If a second domain is required -
Create New Dynamic DNS
in UniFi OS and use the servicedyndns
with the same setup as above