If you have a domain and you are running your servers from home the IP-address will change from time to time, this is called dynamic DNS. In this guide you will learn how to automatically let a Raspberry Pi running Ubuntu server keep your IP-address up to date so that your domain names always are working.

Docker: Easiest install

Make a directory where we will put the docker-compose.yml file.

mkdir ddclient

Next go into the folder.

cd ddclient

Now we create the docker-compose.yml.

nano docker-compose.yml

And paste in the following code

---
services:
  ddclient:
    image: lscr.io/linuxserver/ddclient:latest
    container_name: ddclient
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - ./config:/config
    restart: unless-stopped

Now go ahead with a dummy start of the container.

docker compose up

When there is no more text showing, hit CTRL + C.

Next we’ll edit the ddclient.conf. Personally I use Cloudflare, so I will use it as example here. If you want to use something else just look in the ddclient.conf. It contains a lot of examples.

nano config/ddclient.conf

The config I use for Cloudflare.

daemon=600                              # check every 300 seconds
syslog=yes                              # log update msgs to syslog
#mail=root                              # mail all msgs to root
#mail-failure=root          # mail failed update msgs to root
pid=/var/run/ddclient/ddclient.pid      # record PID in file.
ssl=yes                                 # use ssl-support.  Works with
                                                # ssl-library

## Cloudflare
## basementen.com - Cloudflare
protocol=cloudflare
use=web, web=eth0.me
ttl=1
# Login: Only needed if you are using your global API key. If you are using an API token, set it to "token" (wihtout double quotes).
login=token
# Password: This is either your global API key, or an API token. If you are using an API token, it must have the permissions "Zone - DNS - Edit" and "Zone - Zone - Read". The Zone resources must be "Include - All zones".
password=api-token-here
zone=your-domain.com
your-domain.com
subdomain.your-domain.com
zone=your-second-domain.net
your-second-domain.net
zone=your-third-domain.org
your-third-domain.org

Save the config file and then start up the ddclient.

docker compose up -d

You are now running the latest ddclient and are finished.

Alternative install (Raspberry Pi, etc.): ddclient on the system

Start by installing ddclient.

sudo apt install ddclient

Next step is to edit the config file.

sudo nano /etc/ddclient/ddclient.conf

To set the number of seconds between updates add the following line. 600 seconds is 10 minutes. You can change the number of seconds based on the recommendations of your domain name provider.

daemon=600

To use secure SSL connections, add the following line.

ssl=yes

Depending on which domain name provider you use, the configuration file will be a little different. Here are two examples, one for Cloudflare and one for Namecheap.

## Cloudflare
##
protocol=cloudflare
use=web, web=eth0.me
ttl=1
# Login: Only needed if you are using your global API key. If you are using an API token, set it to "token" (wihtout double quotes).
login=your-login
# Password: This is either your global API key, or an API token. If you are using an API token, it must have the permissions "Zone - DNS - Edit" and "Zone - Zone - Read". The Zone resources must be "Include - All zones".
password=your-password
zone=your-domain.com
your-domain.com
subdomain.your-domain.com
zone=your-second-domain.net
your-second-domain.net
zone=your-third-domain.org
your-third-domain.org
## Namecheap
use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=your-domain.com
password='your-password'
subdomain

To test that the configuration are correct and working, run the ddclient manually with the following command

sudo ddclient -daemon=0 -debug -verbose -noquiet

You should see lines at the end saying SUCCESS, which means it’s working.

Finally, once you verify ddclient is configured correctly, run ddclient as a service. It may already be running, but you will want to restart it to make sure it loads the updated configuration:

sudo service ddclient restart

The service will run in the background and update your domain’s DNS according to the interval you set in the config. To verify it’s running, run

sudo service ddclient status