Skip to content

emizuki/cloudflare-ddns-worker-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare DDNS Worker

A Cloudflare Worker that serves as a customized DDNS provider for Synology NAS, updating DNS records on Cloudflare.

How It Works

  1. Your Synology NAS sends an HTTP request with Basic Auth credentials, hostname, and your current external IP
  2. The worker looks up the Cloudflare DNS zone for the hostname
  3. It creates or updates an A (IPv4) or AAAA (IPv6) record accordingly

Written in Rust, compiled to WebAssembly, and deployed on Cloudflare Workers.

Prerequisites

Deploy

Clone the repository and deploy:

git clone https://github.com/emizuki/cloudflare-ddns-worker-rust.git
cd cloudflare-ddns-worker-rust
npx wrangler deploy

If you have multiple Cloudflare accounts, set CLOUDFLARE_ACCOUNT_ID before 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_PASS

Save the BASIC_USER and BASIC_PASS values — you will need them when configuring your Synology NAS.

Configure Synology DSM

1. Add a Customized DDNS Provider

  1. Go to Control Panel > External Access > DDNS
  2. Click Customize Service Provider
  3. Fill in the fields:
    • Service Provider: Cloudflare
    • Query URL:
      https://<your-worker>.workers.dev/?hostname=__HOSTNAME__&myip=__MYIP__
      
      Replace <your-worker> with your actual worker subdomain.
  4. Click Save

2. Add a DDNS Entry

  1. Go to Control Panel > External Access > DDNS
  2. Click Add
  3. 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_USER value
    • Password/Key: your BASIC_PASS value
  4. Click Test Connection to verify
  5. Click OK

Your Synology NAS will now automatically update the DNS record whenever its external IP changes.

Creating a Cloudflare API Token

  1. Go to the Cloudflare dashboard
  2. Click Create Token
  3. Select Create Custom Token
  4. Configure permissions:
    • Zone - Zone - Read
    • Zone - DNS - Edit
  5. Under Zone Resources, select Include - Specific zone and choose your domain (or All zones)
  6. Click Continue to summary, then Create Token

License

MIT

About

Customized DDNS Provider for Synology NAS on Cloudflare Workers©

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages