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 daemon parameter sets the amount of time after which ddclient will attempt to retrieve the IP address from the Internet uplink routers,
  • syslog means that ddclient will log via the syslog facility,
  • the mail options will be used in case some IP address could not be set - for silent operation it is recommended to comment out the mail lines since the retrieval or setting of IP addresses may fail temporarily

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:

  • use=cmd - use an external script to retrieve the IP address,
  • cmd=/usr/local/sbin/router1-ip - the script /usr/local/sbin/router1-ip will be used to retrieve the IP address from the router,
  • login=username, password=password - attempt to login to Dynu using username as the username and password as the password,
  • server1.dynu.net - update the A record for server1.dynu.net by setting the IP address to the IP address retrieved by the script from the router.

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:

  • /usr/local/sbin/router1-ip and
  • /usr/local/sbin/router2-ip

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.


networking/multihomed_dynamic_dns.txt · Last modified: 2022/04/19 08:27 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.