A Cloudflare Worker that serves as a customized DDNS provider for Synology NAS, updating DNS records on Cloudflare.
- Your Synology NAS sends an HTTP request with Basic Auth credentials, hostname, and your current external IP
- The worker looks up the Cloudflare DNS zone for the hostname
- It creates or updates an A (IPv4) or AAAA (IPv6) record accordingly
Written in Rust, compiled to WebAssembly, and deployed on Cloudflare Workers.
- A domain on Cloudflare
- A Cloudflare API token
- Rust toolchain and Wrangler CLI for deployment
- Synology NAS running DSM 7
Clone the repository and deploy:
git clone https://github.com/emizuki/cloudflare-ddns-worker-rust.git
cd cloudflare-ddns-worker-rust
npx wrangler deployIf you have multiple Cloudflare accounts, set
CLOUDFLARE_ACCOUNT_IDbefore deploying:CLOUDFLARE_ACCOUNT_ID=your_account_id npx wrangler deploy
Then set the required secrets:
# Cloudflare API token
npx wrangler secret put CF_API_TOKEN
# Generate and set credentials for Basic Auth
openssl rand -hex 32 # use output as BASIC_USER
npx wrangler secret put BASIC_USER
openssl rand -hex 32 # use output as BASIC_PASS
npx wrangler secret put BASIC_PASSSave the BASIC_USER and BASIC_PASS values — you will need them when configuring your Synology NAS.
- Go to Control Panel > External Access > DDNS
- Click Customize Service Provider
- Fill in the fields:
- Service Provider:
Cloudflare - Query URL:
Replace
https://<your-worker>.workers.dev/?hostname=__HOSTNAME__&myip=__MYIP__<your-worker>with your actual worker subdomain.
- Service Provider:
- Click Save
- Go to Control Panel > External Access > DDNS
- Click Add
- Fill in the fields:
- Service provider:
Cloudflare(the one you just created) - Hostname: your full domain, e.g.
nas.example.com - Username/Email: your
BASIC_USERvalue - Password/Key: your
BASIC_PASSvalue
- Service provider:
- Click Test Connection to verify
- Click OK
Your Synology NAS will now automatically update the DNS record whenever its external IP changes.
- Go to the Cloudflare dashboard
- Click Create Token
- Select Create Custom Token
- Configure permissions:
- Zone - Zone - Read
- Zone - DNS - Edit
- Under Zone Resources, select Include - Specific zone and choose your domain (or All zones)
- Click Continue to summary, then Create Token
MIT