How to update cloudflare dns with ddclient in docker
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 creating a record in a zone in cloudflare and using ddclient to monitor and update the record's ip when it changes.
I found a few blog and forum posts about how to use ddclient with cloudflare but it still took some hacking to get everything working. I've created this repo to bridge the gap between what's online and what it takes to get ddclient and cloudflare wired up.
- Cloudflare deprecated the api version that ddclient originally used -- https://www.cloudflare.com/migrating-to-v4/
- The version of ddclient in the ubuntu focal repo (3.8.3) still uses cloudflare's deprecated api. To get the latest version, this repo installs ddclient from github.
- Create a cloudflare api token using the
Edit Zone DNStemplate. ForZone ResourcesselectAll zones- https://developers.cloudflare.com/api/tokens/create - Clone this repo
git clone https://github.com/pedrorito/ddclient-cloudflare-docker.git
cd ddclient-cloudflare-docker
- Update the following in ddclient.conf. If needed, here's some config examples from the source
- password=
- zone=
- RECORD_TO_UPDATE
- Start the container
docker-compose up -d
ddclient's logs are captured by docker. They're available by running docker-compose logs -f ddclient. Successful logs should look similar to:
SUCCESS: $record -- Updated Successfully to $ip
- To enable verbose logging, in ddclient.conf set
verbose=yesthen rundocker-compose restart ddclientto 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