Setup Dynamic DNS

Synopsis:

Dynamic Domain Name Service or just plain DDNS, allows a host with a fixed or dynamic IP address to be dynamically linked to a name through a DDNS service provider such as the free service from Dynu (https://www.dynu.com). No domain name registration is required, but amazingly, it is optionally supported. This means that if you do have your own registered domain, you can link it to your machine that has a dynamic IP!! This is way better than the old, no longer free, dyndns.org

First you must register for a free Dynu account, then you can use a choice of their existing TLD (top level domains) and add your host name. Your registered username and password will be used in the configuration file which will be described below. It is also possible to create separate username and password and not use your Dynu account login (for security). You can assign your hostname or link your registered domain name through Dynu website. If using your own domain name, you will use Dynu DNS servers for DNS with your Domain Name provider (Network Solutions, Godaddy, etc.) and also create an 'alias' for your hostname through the Dynu website setup. You will then be able to find your host by using a real name, i.e. http://myserver.dynu.com.


I. Installation

We will use the DDNS client program ddclient, which will monitor your FreeBSD server's IP address every minute and report any changes to the Dynu IP update server. Log into the Freebsd system as root. (Assumes networking is already configured.)

#
# cd /usr/ports/dns/ddclient && make install clean
Installing ddclient-3.9.1...
#
II. Startup Configuration
Add the startup to /etc/rc.conf
#
# sysrc ddclient_enable="YES" >> /etc/rc.conf
#
III. Configuration
Create and edit the /usr/local/etc/ddclient.conf file, paste in the below text and modify as required.
# ddclient configuration for Dynu
#
# /usr/local/etc/ddclient.conf
daemon=60                        # Check every 60 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.pid        # Record PID in file.
ssl=yes                          # Use ssl-support.  Works with ssl-library .
use=if, if=tun0                  # Get ip from hardware interface.
server=api.dynu.com              # IP update server.
protocol=dyndns2                        
login=myloginame                 # Your username.
password=mypassword              # Your password or MD5 of password.
mydomain.com&alias=www           # Update IP address for alias of your domain name

Make sure to modify the above if= interface (tun0 is the interface when network attaches with PPPoE), your Dynu login name, your Dynu login password, your domain name and your hostname (alias).

Make the configuration file read/writable by root only.
#
# chmod 600 /usr/local/etc/ddclient.conf
#
To start ddclient, either reboot your system or:
#
# service ddclient start
#