CloudFlare DDNS setup guide
Trap
CloudFlare Docs for DDNS recommends using DDClient, however API1 (www.cloudflare.com) used by DDClient is already deprecated. Thus DDClient is not usable for CloudFlare right now and even if you dig on forums, there are no recent solutions. You will run into the HTTP 403 (The CloudFlare "You are blocked" page) trouble when using DDClient cloudflare protocol, plus it does not log any error on it (you will need -verbose -debug
and read all the HTTP response bodies to learn about this failure).
Good approach for now
CloudFlare-DDNS prodives a lightweight python script for auto update IP addresses.
Setup Docker
:warn: Running docker as non-root user is not covered in this solution.
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
sudo apt install docker-compose -y
Setup CloudFlare-DDNS
mkdir -p ~/cloudflare-ddns
cd ~/cloudflare-ddns
Create an API Token in CloudFlare Profile with DNS-Edit
permission.
Create these files
config.json
{
"cloudflare": [
{
"authentication": {
"api_token": "<Your API Token in CloudFlare Profile>"
},
"zone_id": "<Your Zone ID for the domain>",
"subdomains": [
{
"name": "<subdomain name, leave empty for root>",
"proxied": <true|false>
}
]
}
],
"a": true,
"aaaa": false,
"purgeUnknownRecords": false,
"ttl": 300
}
Note: leave "aaaa": false
for Google Cloud VM as it does not support IPv6 by default.
docker-compose.yml
version: '3'
services:
cloudflare-ddns:
image: timothyjmiller/cloudflare-ddns:latest
container_name: cloudflare-ddns
security_opt:
- no-new-privileges:true
network_mode: 'host'
environment:
- PUID=1000
- PGID=1000
volumes:
- /home/<user-name>/cloudflare-ddns/config.json:/config.json
restart: unless-stopped
Note: always specify the absolute path instead of ~
if you are using sudo docker-composer.
sudo docker-compose up -d
sudo docker logs cloudflare-ddns
If success,
sudo systemctl enable docker
If failed, after editing any config,
sudo docker-compose down
Discussion