How to update Cloudflare DNS with ddclient
I had a need to use DNS for a personal project and went down the rabbit hole of dynamic DNS. Instead of using a DDNS provider, I settled on hosting a zone in Cloudflare and using ddclient to keep a record up-to-date.
I found some stuff online about using ddclient with Cloudflare but it took some hacking to get everything working.
- Cloudflare deprecated the API that ddclient originally used.
- The version of ddclient in the ubuntu focal repo (3.8.3) still uses Cloudflare's deprecated API. To get the latest version, you have to install ddclient from Github.
It's assumed the reader has a Cloudflare account and a DNS zone.
- Create the DNS record you want to manage with ddclient.
- Create a Cloudflare API token using the
Edit Zone DNS
template. ForZone Resources
selectAll zones
. ref - Clone this repo.
git clone https://github.com/alexcreek/cloudflare-ddclient-guide.git ddclient
cd ddclient
- Update the following in ddclient.conf.
- password=
- zone=
- RECORD_TO_UPDATE
- Start the ddclient container.
docker-compose up -d
Check ddlient's logs for SUCCESS messages.
docker-compose logs -f ddclient
should yield:
SUCCESS: $record -- Updated Successfully to $ip
- To enable verbose logging, in ddclient.conf set
verbose=yes
then rundocker-compose restart ddclient
to restart the container. - To execute commands from the project's troubleshooting docs, open a shell in the container by running
docker-compose exec ddclient bash