What's Dynamic DNS?
Dynamic DNS is a mechanism to automatically update DNS records with the location of a device or system. Systems that have "floating" IP addresses (such as most home consumer internet connections) need Dynamic DNS to have a constantly addressable domain name.
Configuration Steps
Get your Cloudflare Global API Key
- Head to https://cloudflare.com and log in
- In the profile drop-down in the top-right, select My Profile
- From the tabs at the top, select API Tokens
- Under API Keys, next to Global API Key, select View
- If required, re-enter your password / solve the CAPTCHA
- Copy down the Global API Key shown
On your server, get your user's UID and GID
- You can get your UID with
id -u username
- You can get your GID with
id -g username
- You can get your UID with
On your server, create a new
ddclient
folder- The folder will be copied wholesale into the container, so you don't want too much garbage in it
In this folder, create a new
ddclient.conf
file, with the following contents:ddclient.confuse=web, web=ipinfo.io/ip protocol=cloudflare, \ zone=<your zone>, \ login=<your cloudflare login email>, \ password=<your global API key> \ <DNS record to update>
So, for example:
Example ddclient.confuse=web, web=ipinfo.io/ip protocol=cloudflare, \ zone=example.com, \ login=me@example.com, \ password=e3199589b1476ebca5c8547f780da80843431 \ server.example.com
NOTE: There is no comma after the
password
entry!WARNING: The Global API key is essentially the same as your cloudflare password: Make sure you don't accidentally check it into source control!
Also in the folder, create a new
docker-compose.yml
file, with the following contents:docker-compose.ymlversion: "3.7" services: ddclient: image: linuxserver/ddclient container_name: ddclient environment: - PUID=<Your user's UID> - PGID=<Your user's GID> - TZ=<Your timezone> volumes: - .:/config restart: unless-stopped
So, for example:
Example ddclient.confversion: "3.7" services: ddclient: image: linuxserver/ddclient container_name: ddclient environment: - PUID=1001 - PGID=1001 - TZ=Europe/London volumes: - .:/config restart: unless-stopped
Start the ddclient service
- In the folder, run
docker-compose up -d
- (You may need to run
sudo
beforehand.)
- (You may need to run
- In the folder, run
That's it! You should now have a functional ddclient instance creating and
updating a DNS A
record in cloudflare DNS. The restart
setting will
ensure the container restarts if the hosting server restarts.
If the record doesn't seem to be updating, you can check the logs of the
running container with docker logs ddclient
.