Set up Dynamic DNS with Cloudflare on Synology DSM 6

DDNS

In the Synology DSM there are several DDNS services available. Unfortunately Cloudflare isn’t among them. But there is a way to get it up and running thanks to joshuaavalon at github.

First of all you need a domain name already using cloudflare. If you don’t, there might not be any reason for you to read this tutorial.

Steps

  1. Download and install script to NAS
  2. Get needed info from Cloudflare
  3. Update the script
  4. Activate DDNS in DSM

1. Download and install script to NAS

a. log in to your nas with SSH as admin. If SSH isn’t activated, do the following

  • Login to your DSM
  • Go to Control Panel > Terminal & SNMP > Enable SSH service
  • Open a terminal of choice and type ssh [email protected] or IP

b. Download cloudflareddns.sh from joshuavalons githup repository to /sbin/cloudflaredns.sh by entering the following command

sudo wget https://raw.githubusercontent.com/joshuaavalon/SynologyCloudflareDDNS/master/cloudflareddns.sh -O /sbin/cloudflaredns.sh


c. Change permissions of cloudflareddns.sh file

sudo chmod +x /sbin/cloudflaredns.sh

d. Add cloudflareddns.sh to synology by pasting the following lines into your terminal and press enter.

sudo echo "[Cloudflare]">>/etc.defaults/ddns_provider.conf
sudo echo " modulepath=/sbin/cloudflaredns.sh">>/etc.defaults/ddns_provider.conf
sudo echo " queryurl=https://www.cloudflare.com/">>/etc.defaults/ddns_provider.conf

2. Get needed info from Cloudflare

a. Log in to your cloudflare account and select the domain you intend to use and go to “overview”.
b. Copy your “Zone ID:”
c. Copy your API key by selecting “Get your API key”

cloudflare-overview

d. Edit the script below by replacing keys with the keys your retrieved earlier.
e. Get your record ID by pasting the updated script in your terminal and press enter.

curl -X GET "https://api.cloudflare.com/client/v4/zones/xxxxxxxxxxZONE-IDxxxxxxxxxxxxxx/dns_records" \
   -H "X-Auth-Email: [email protected]" \
   -H "X-Auth-Key: xxxxxxxxxxxxxAPI-KEYxxxxxxxxxxxxxxxx" \
   -H "Content-Type: application/json"


The record ID is the first ID listed in the output {“result”:[{“id”:”xxxxxxxxxxxRECORD-IDxxxxxxxxxxxxxxx“..

 

3. Update the script

a. You now need to update /sbin/cloudflaredns.sh with the paramaters you have retrieved. I do this with Nano because vim doesn’t make sense =)
If you don’t have nano installed you can do it by installing entware or optware. I recommendthe following guide keestalkstech.com
in the script scroll down and edit the followin paramaters.

# CloudFlare Config
__RECTYPE__="A"
__RECID__="xxxxxxxxxxxRECORD-IDxxxxxxxxxxxxxxx"
__ZONE_ID__="xxxxxxxxxxZONE-IDxxxxxxxxxxxxxx"
__TTL__="1"
__PROXY__="true"

4 Activate DDNS in DSM

a. Log in to DSM, open the control panel and go to External Access and click Add under DDNS

b. Choose Cloudflare as service and enter your details in the DDNS window. Your password is your API-KEY and not your cloudflare password.

DDNS

You should be all set! If not, don’t hesitate to comment and I’ll see if I can help.

Oh and as usual, if something breaks, blame the bad guys..

 

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.