Skip to content

Instantly share code, notes, and snippets.

@guerrerocarlos
Last active February 11, 2024 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guerrerocarlos/7adcaf5ca507b5cc92a966e9105feabe to your computer and use it in GitHub Desktop.
Save guerrerocarlos/7adcaf5ca507b5cc92a966e9105feabe to your computer and use it in GitHub Desktop.
How to setup DDclient on Raspberry Pi for use with Namecheap DynDNS

How to use CloudFlare DNS service to update your Dynamic IP with ddclient on the Raspberry Pi

CloudFlare related resource

https://developers.cloudflare.com/dns/manage-dns-records/how-to/managing-dynamic-ip-addresses/

Dependencies

Assuming you have a clean raspberry pi installation, you will need to install:

sudo apt install autoconf

Install ddclient

Clone their repo and follow their instructions, in this step, the best is to follow their latest instructions:

https://github.com/ddclient/ddclient

Get an API token from CloudFlare

Go to https://dash.cloudflare.com/profile/api-tokens and click:

  • [API Tokens]
  • [Create Token]
  • Edit Zone DNS -> [Use Template]
  • Select if you want the token to control a specific zone or have edit access to all your zones
  • [Continue to summary]
  • [Create Token]

Setup your config

After we have installed ddclient, we must now adjust its configuration file. The path of the file is:

/etc/ddclient/ddclient.conf

Search for the word "Cloudflare" and edit that section as follows:

##
## CloudFlare (www.cloudflare.com)
##
protocol=cloudflare,                      \
zone=___DOMAIN___,                        \
ttl=1,                                    \
login=token,                              \
use=web,                                  \
web=https://cloudflare.com/cdn-cgi/trace, \
web-skip="ip=",                           \
password=___CLOUDFLARE_TOKEN_GOES_HERE___ \
__SUBDOMAIN__.___DOMAIN___

Test your config

Check if your configuration is working properly by executing:

ddclient -daemon=0 -debug -verbose -noquiet

Note

Note that this will try to Update your DNS record, so the record must already exist, else it will not create it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment