UniFi DDNS doesn't support Cloudflare in the UI. This repo is a proxy to fwd UniFi DDNS updates to Cloudflare.
With typical usage, free tier should be plenty.
- Find your API key:
- https://dash.cloudflare.com/profile/api-tokens > Global API Key
- Find domain zone id:
- domain's Overview page, right sidebar,
Zone IDvalue
- domain's Overview page, right sidebar,
- Find DNS record id:
- add/edit an A record with a temporary ip, ie
home.mydomain.com=127.0.0.1 - navigate cloudflare dashboard > Manage Account > Audit Log
- expand most recent log, copy the
Resource IDvalue
- add/edit an A record with a temporary ip, ie
- Download
cloudflare-ddns.zipfrom https://github.com/frifox/cloudflare-ddns/releases - Or build it yourself:
git clone github.com/frifox/cloudflare-ddns
cd cloudflare-ddns
GOOS=linux GOARCH=arm64 go build -o bootstrap -tags lambda.norpc -ldflags "-s -w"
zip cloudflare-ddns.zip bootstrap- Goto AWS Lambda (https://console.aws.amazon.com/lambda/home)
- Click
Create Function:- select
Author from scratch - name your function, ie
cloudflare-ddns - set Runtime
Amazon Linux 2023 - set Architecture
arm64 - under
Advanced settings:- check
Enable function URL - set Auth Type
NONE
- check
Create function
- select
- Under
Codetab:Upload from>.zip file>Upload- find your
cloudflare-ddns.zip Save
- Under
Configurationtab:Function URL> copy the url, will be used in UniFi later
- Under
ConfigurationtabEnvironment variables>Edit>Add environment variable- add Key/Values:
APP_USER= pick a username for your lambda appAPP_PASS= pick a password for your lambda appCF_EMAIL= login email for cloudflareCF_KEY= cloudflare global api keyCF_ZONE_ID= cloudflare domain's zone idCF_RECORD_ID= cloudflare domain's A record id
- and optionally:
CF_RECORD_PROXIED= use cloudflare proxytrue/false(defaultfalse)CF_RECORD_TTL= record TTL in seconds, requiresCF_RECORD_PROXIED=false(default3600)
- Go to https://unifi.ui.com/ > Your console
- Go to Settings > Internet > Primary (or Secondary)
- Under
Dynamic DNS, clickCreate New Dynamic DNS:- Service =
custom - Hostname = your FQDN, ie
home.mydomain.com - Username =
APP_USERvalue - Password =
APP_PASSvalue - Server =
{your_aws_lambda_function_url.aws}/?hostname=%h&ip=%i- IMPORTANT: remove the
https://prefix from your aws lambda function url
- IMPORTANT: remove the
Save
- Service =
- Go to https://unifi.ui.com/ > Your console
- Go to UniFi Devices > your router/gateway > on right sidebar: Settings > Debug
- Once you get the shell, find inadyn conf file location & force it to update:
# ps x | grep inadyn.conf
2668706 ? S< 0:00 /usr/sbin/inadyn -n -s -C -f /run/ddns-ppp0-inadyn.conf
# inadyn -n -1 --force -f /run/ddns-ppp0-inadyn.conf
inadyn[2908558]: In-a-dyn version 2.9.1 -- Dynamic DNS update client.
inadyn[2908558]: Update forced for alias home.mydomain.com, new IP# 123.123.123.123
inadyn[2908558]: Updating cache for home.mydomain.com- Login to cloudflare and verify dns record updated