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.
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:
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.
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:
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 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.
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.
ddclient –debug –verbose -foreground
on the command line and ddclient
should proceed to update the A records for your chosen DNS name.Issue:
systemctl enable ddclient
followed by:
systemctl start ddclient
to enable the ddclient
service, respectively start ddclient
in the background as a daemon.