Run commands in Synology
- 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.
- Give others execute permission
chmod +x /usr/local/sbin/cloudflaredns.sh
- Add
cloudflareddns.sh
to Synology
cat >> /etc.defaults/ddns_provider.conf << 'EOF'
[Cloudflare]
modulepath=/usr/local/sbin/cloudflaredns.sh
queryurl=https://www.cloudflare.com/
EOF
queryurl
does not matter because we are going to use our script but it is needed.
Get Cloudflare parameters
- Go to your domain overview page and get the Zone ID.
- Go to your account setting page and get API Key.
- 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
- Enter the parameters to the
cloudflareddns.sh
. - Login to your DSM
- Go to Control Panel > External Access > DDNS > Add
- 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'
[Cloudflare]
modulepath=/usr/local/sbin/cloudflaredns.sh
queryurl=https://www.cloudflare.com/
Leave a Reply