Synology Cloudflare DDNS Script

Synology Cloudflare DDNS Script

Run commands in Synology

  1. Download cloudflareddns.sh from this repository to /usr/local/sbin/cloudflaredns.sh
wget https://raw.githubusercontent.com/joshuaavalon/SynologyCloudflareDDNS/master/cloudflareddns.sh -O /usr/local/sbin/cloudflaredns.sh

If you put the script in other name or path, make sure you use the right path.

  1. Give others execute permission
chmod +x /usr/local/sbin/cloudflaredns.sh
  1. Add cloudflareddns.sh to Synology
cat >> /etc.defaults/ddns_provider.conf << 'EOF'

queryurl does not matter because we are going to use our script but it is needed.

Get Cloudflare parameters

  1. Go to your domain overview page and get the Zone ID.
  2. Go to your account setting page and get API Key.
  3. Get record id using Cloudflare API.
curl -s GET "https://api.cloudflare.com/client/v4/zones/[Zone ID]/dns_records" \
	-H "X-Auth-Email: [Email]" \
	-H "X-Auth-Key: [API Key]" \
	-H "Content-Type: application/json" \
	| jq '.result[] | {name, id, zone_id, zone_name, content, type}'

You need to replace with [] with your parameter. Then, you get the id in result which is you Record ID.

Setup DDNS

  1. Enter the parameters to the cloudflareddns.sh.
  2. Login to your DSM
  3. Go to Control Panel > External Access > DDNS > Add
  4. Select Cloudflare as service provider. Enter your domain as hostname, your Cloudflare account as Username/Email, and API key as Password/Key

Known Issue

This DDNS entry will usually be broken after DSM major firmware update. What you need to do is to repeated add below lines to /etc.defaults/ddns_provider.conf file after upgrade.

cat >> /etc.defaults/ddns_provider.conf << 'EOF'
Written by Felix. Licensed under CC BY-NC-SA 3.0 Unported.

Leave a Reply


  • Nnyan

    I keep getting the following error:

    parse error: Invalid numeric literal at line 1, column 18

    5 years ago Reply
  • Danila Vershinin

    A better Cloudflare DDNS provider for Synology can be found here: https://github.com/dvershinin/cloudflareddns

    * Can be configured via root domain record, e.g. example.com as your DDNS name
    * Installable via pip
    * Correctly handles domains with country suffixes like .co.uk, etc.

    5 years ago Reply


Synology Cloudflare DDNS Script
Run commands in Synology Download cloudflareddns.sh from this repository to /usr/local/sbin/cloudflaredns.sh wget https://raw.githubusercontent.com/joshuaavalon/Synol…
Scan QR code to continue reading