Table of Contents

About

Following the router zone update for Cloudflare, for some usage cases, a free DNS provider such as Dynu is sufficient for maintaining an easy to remember address.

The following guide uses the Dynamic DNS Client software (ddclient) available on Linux in order to map multiple IP addresses to DNS A records on the Dynu.com free dynamic DNS service.

Network Diagram

The scenario is a typical multi-homed server with two Internet uplinks that provide two distinct IP addresses, say, 95.173.136.70 and 104.68.185.195.

+-----------------------+                +-----------------------+     
|                       |                |                       |     
|   server1.dynu.net    |                |   server2.dynu.net    t     
|                       |                |                       |     
+-----------------------+                +-----------------------+     
            ^                                        ^                 
            |                                        |                 
            |                                        |                 
+-----------+----------------------------------------+-----------+     
|                                                                |     
|                           Dynu.com                             |     
|                                                                |     
+-----------+----------------------------------------+-----------+     
            |                                        |                 
            |                                        |                 
            | 95.173.136.70                          |  104.68.185.195 
            v                                        v                 
     +-------------+                          +-------------+          
     |             |                          |             |          
     |  Internet   |                          |  Internet   |          
     |   Uplink    |                          |   Uplink    |  . . . . 
     |    Router   |                          |    Router   |          
     |             |                          |             |          
     +-------------+                          +-------------+          
            v                                        v                 
            |                                        |                 
            +--------------------+-------------------+                 
                                 |                                     
                                 v                                     
                          +------------+                               
                          |            |                               
                          |   Server   |                               
                          |            |                               
                          +------------+                               

The server will have to, in order:

  1. obtain the external IP addresses for both uplinks via a script
  2. inform Dynu if there have been any recent changes

Setting up an Account

A free account has to be created on Dynu.com and two or more dynamic DNS hostnames have to be registered for each uplink. Dynu provides a list of DNS names to chose from. For this example, dynu.net has been used as the DNS terminator and server1, respectively server2 as the hostnames for both uplinks.

Setting Up Dynamic DNS Client

On Debian, ddclient can be installed by issuing:

aptitude install ddclient

after which Debian will prompt to configure ddclient - any values should suffice, for now, since the whole configuration file shall be replaced by a different configuration.

That being said, edit /etc/ddclient.conf and enter the following configuration:

# ddclient configuration for Dynu
#
# /etc/ddclient.conf

daemon=60
syslog=yes
mail=root
mail-failure=root
pid=/var/run/ddclient.pid

use=cmd, \
cmd=/usr/local/sbin/router1-ip, \
server=api.dynu.com, \
protocol=dyndns2, \
login=username, \
password='password', \
server1.dynu.net

use=cmd, \
cmd=/usr/local/sbin/router2-ip, \
server=api.dynu.com, \
protocol=dyndns2, \
login=username, \
password='password', \
server2.dynu.net

where:

The following multiline configuration block meant for the router corresponding to the dynamic DNS name server1.dynu.net:

use=cmd, \
cmd=/usr/local/sbin/router1-ip, \
server=api.dynu.com, \
protocol=dyndns2, \
login=username, \
password='password', \
server1.dynu.net

will:

Note that the password password must be surrounded by single quotes.

Writing Scripts

Both configuration blocks in the example from the previous section use two shell scripts:

That will retrieve the IP address from two different routers. These scripts are somewhat easier than the ones presented on the router zone update page because the scripts will just echo the IP address to STDOUT rather than updating CloudFlare. In effect, the scripts in the router zone update section can just be cropped to just print out the IP address which is what ddclient expects when cmd=/usr/local/sbin/router1-ip, is specified.

Debugging

  1. Log in to the Dynu DDNS control panel and watch the hostname to address mapping.
  2. Issue: ddclient –debug –verbose -foreground on the command line and ddclient should proceed to update the A records for your chosen DNS name.

Running Continuously

Issue:

systemctl enable ddclient

followed by:

systemctl start ddclient

to enable the ddclient service, respectively start ddclient in the background as a daemon.