Dynamic DNS using Raspberry PI

Dynamic DNS allows you to automatically update the IP resolved to a specific hostname. But the problem is the update client will only run if your computer is turned on (which you can't for 24 hours). But a Raspberry PI can be 24/7 running, which can be used for updating your DNS entry as it changes.

Posted by Darwin Biler on February 20, 2016

When I need to step outside my house, sometimes I need to access some files in my computer and NAS server. The problem is, as we all know, the normal Internet lines issued for residential packages has dynamic IP.That means the IP address of your router is constantly changing unpredictably.

For that reason, I cannot simply access my files at home, being I don't know what is the most current IP address of my router. The solution to this is to have a DDNS (Dynamic DNS).

Vitalwerks Internet Solutions offers a free service called NoIP. This allows you to have a yourname.ddns.net which can be binded to the current IP address of your router.

In order for NoIP to update your DDNS entry, some device at your home needs to submit the current IP address of your router. Today, we are going to use the Linux client installed in a Raspberry PI box.

Mine was a Raspberry Pi 2 Model B with 1GB RAM Board. I had installed Raspbian on it and had it is connected to my router via RJ-45 cable. I had the device running 24/7 and is the ideal device for performing DDNS update.

To start with, login to your Raspberry PI box and download the DDNS client

cd /usr/local/src/
sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
sudo tar xf noip-duc-linux.tar.gz
cd noip-2.1.9-1/
sudo make install

The above will install the noip2 executable in /usr/local/bin/

Then you need to create the configuration file. Note that the config file is not plain text file. and the values there is encrypted.

sudo /usr/local/bin/noip2 -C

This will create a file under /usr/local/etc/no-ip2.conf

Now start the client by:

sudo /usr/local/bin/noip2

It will now start updating your DDNS entries to your current IP. To check the progress and any issue, check the logs by

tail /var/log/syslog

It will show up something like this

Feb 20 12:36:21 raspberrypi noip2[18282]: v2.1.9 daemon started with NAT enabled
Feb 20 12:36:26 raspberrypi noip2[18282]: xxxx.ddns.net set to x.x.x.x
...

Note that I had replaced the info above with x, but in reality, those will be the actualy ddns host and IP of your router.

And now you are done! the client will update the ddns entry each time your IP changes. This opens a lot of possiblities

  • Access your home network using the DDNS url
  • apply a CNAME record so you can point a domain you own to a custom domain, for example mynetwork.darwinbiler.com instead of the generic mynetwork.ddns.net
  • Host a website in your home

There is a lot of other possibilites in there and its only limited by your imagination!