Setting up Cloudflare DDNS in Synology

In order to host a web server at home using Cloudflare’s DNS service, I found a docker timothyjmiller/cloudflare-ddns quite convenient for configuring. And here’s the steps to set up in a Synology DSM:

SSH to the DSM, then create this directory:

/volume1/docker/cloudflare-ddns

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
version: '3.9'
services:
  cloudflare-ddns:
    image: timothyjmiller/cloudflare-ddns:latest
    container_name: cloudflare-ddns
    security_opt:
      - no-new-privileges:true
    network_mode: 'host'
    volumes:
      - /volume1/docker/cloudflare-ddns/config.json:/config.json
    restart: unless-stopped

Create the API token from Cloudflare’s dashborad, or open this link:

https://dash.cloudflare.com/profile/api-tokens/

Make sure it has DNS:Edit permission.

/setup-cloudflare-ddns-in-synology/api_token.png

Copy the token and save it somewhere because it only shows one time on the website!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "cloudflare": [
    {
      "authentication": {
        "api_token": "Cloudflare_API_Token_Here"
      },
      "zone_id": "Cloudflare_ZoneID_Here",
      "subdomains": [
        {
          "name": "aaa",
          "proxied": true
        },
        {
          "name": "bbb",
          "proxied": false
        }
      ]
    }
  ],
  "a": false,
  "aaaa": true,
  "purgeUnknownRecords": false,
  "ttl": 300
}

More detailed explanation can be found here:

https://github.com/timothymiller/cloudflare-ddns#-example-

The folder should look like this:

/setup-cloudflare-ddns-in-synology/docker_files.png

With this script:

docker-compose up -d

Related Content