Hi everyone!
Here is a small tutorial on how to set up your DDClient for updating IP addresses for your domains on Cloudflare and NameCheap.
In my case I am using DDClient in Docker with a single configuration file for updating both Cloudflare and NameCheap domains.
First things first, here is a sample configuration file for DDClient that will update your domains.
Save this file on dedicated location that DDClient Docker container will use and save it with a name:
ddclient.conf
#######################
# General configuration
#######################
daemon=300
syslog=yes
ssl=yes
use=web,web=ipify-ipv4
####################
# Protocol Namecheap
####################
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=example.com
password=****************
@
####################
# Protocl Cloudflare
####################
protocol=cloudflare
server=api.cloudflare.com/client/v4/
login=token
password='****************'
zone=example.com
www.example.com,ftp.example.com,blog.example.com
Explanation for parts of the configuration file:
daemon=300
syslog=yes
ssl=yes
use=web,web=ipify-ipv4
Here I am using some DDClient options that are shared between Cloudflare and NameCheap protocols.
Keep in mind that official document for NameCheap has the use=,web= defined differently, for me it didn’t work fine and in the end I changed it according to these settings that get the Public IP correctly for both Cloudflare and NameCheap.
login=example.com
password=****************
@
Here you must enter name of your NameCheap domain and specifiy the Host for which the IP address will be updated.
In my case I have @ defined for my domain host on NameCheap admin DNS settings, which will resolve all sub domain requests for my domain (like www.example.com, ftp.example.com or blog.example.com) point to the same IP that DDClient will update.
login=token
password='****************'
zone=example.com
www.example.com,ftp.example.com,blog.example.com
In this section for Cloudflare I am using a dedicated token for updating IP addresses for my Cloudflare Zone (or domain).
This token is something you must set up on your Cloudflare admin dashboard (create it, assign proper permissions on zones) and note the secret token password.
For DDClient Cloudflare configuration you must specify the zone (or domain) for which IP addresses will be updated and in the following line (below) you must specify all sub domain names or hosts that you have defined on Cloudflare DNS page for your domain.
Now, lets create a docker-compose.yaml file that will deploy our DDClient Docker container:
services:
ddclient:
image: linuxserver/ddclient:4.0.0
container_name: ddclient
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Berlin
volumes:
- /path/to/ddclient/config:/config
restart: unless-stopped
Lets break down this docker-compose.yaml file sections to provide some context:
image - specifies the Docker image that is used for this Docker container (I prefer specifying the exact version instead of :latest tag to know exactly which one is deployed)
PUID/PGID - used to set Linux user and group which will be used for running the Docker container (adjust accordingly if needed, but in most cases 1000:1000 will be good)
TZ - Change time zone for you local area if needed
volumes - it is best to create a dedicated folder that will store your DDClient conf files and then mount that folder (which contains previously created ddclient.conf) into Docker container as specified (under /config mount point)
restart - set as needed, I prefer that Docker container always tries to restart unless I stopped it manually
When you have a configured ddclient.conf file along with docker-compose.yaml file adjusted to your needs, you can go ahead and start the Docker container by running the following command from withing the folder in which docker-compose.yaml can be found:
docker compose up -d
You should see the status of Docker container getting created and if everything goes well, the Docker container will remain up&running.
Now you can check the Docker container logs to see if your domain IPs are getting updated by running the following command:
docker logs ddclient
Hope this helps, it sure did help me.
Previously I hd this configured directly on my Linux server and in case of OS reinstall or similar activity I had to go through the entire setup again.
After few ties I decided to resolve this by using Docker, since it’s easy to transfer between servers and restore operation if needed after fresh install with minimal configuration changes on Linux host OS.