When accessing your homeserver over the Internet, you probably have experienced one problem: your public (WAN) IP-address changes from time to time and you can't figure out the new address as long as you are not in your home network. So here is a solution called Dynamic DNS.

When you are using dynamic DNS, all you have to do is register at a DynDNS-provider, choose your URL (for example, homeserver.dyndns.com) and configure your server to update the WAN IP-address whenever it changes. After that, you will have the possibility to access your server by using the chosen URL and the DynDNS-provider will point the connection to the right IP-address.

I am using the service from www.dyndns.com, which offers two Dynamic DNS hosts in 18 different domains for free.

 

Register and choose address

Go to www.dyndns.com and register for an account. After logging in, select "Add Host Services" to create a new dynamic DNS domain name.

For the Service Type, select "Host with IP address". You can then already set your WAN IP-address. After saving the new dynamic DNS URL, it takes a while until it becomes active. After a few minutes you should already be able to connect to your server by using your new URL.

 

Install ddclient and initial configuration

Now we need to configure the server to update the WAN IP-address on dyndns.org as soon as it changes. I am using ddclient which works with many different dynamic DNS providers and offers different possibilities to obtain the WAN IP-address.

Install ddclient from the repository

apt-get install ddclient

After the download finished, it automatically starts the ddclient configuration. At first select your DynDNS provider. As mentioned before, I use dyndns.com:

Select DynDNS provider

Then enter your domain names which you registered before:

Enter registered domain names

Now enter username and password which you use for the login on dyndns.com

Enter usernameEnter password

And if you have more than one network interface (which is the case on the GuruPlug Server Plus), enter the one you want to use

Select interface

After setting the network interface, the installation finishes.

 

Edit configuration files

Now lets take a look at the configuration file (/etc/ddclient.conf) of ddclient (open with vim). Right after the installation, mine looks like this (the capital words are just replacement of course):

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=eth0
server=members.dyndns.org
login=USERNAME
password='PASSWORD'
DOMAINNAME1,DOMAINNAME2

Now what I want is that it gets my public (WAN) IP-address from the web, since my interface eth0 does not have the public IP-address.

Thus, I replaced the line

use=if, if=eth0

with the line

use=web, web=checkip.dyndns.org

Now it will take the IP-address from checkip.dyndns.org.

 

The second configuration file for ddclient is /etc/default/ddclient. It defines how ddclient has to do its work.

The things that I want is that ddclient runs in the background as deamon. As soon as the IP-address changes, it updates the DynDNS service. I also want ddclient to do an update every 5 minutes.

The two important lines are

run_daemon="true"

which sets the daemon-mode as I want it to, and

daemon_interval="300"

which sets the update interval to 5 minutes, also as I want it to.

 

Run ddclient manually

If you want to check if updating the IP-address works or if you just want to perform an update manually, you can run

sudo ddclient

and the IP-address will be updated in case it changed.

 

 

Sources: