DynDNS for your Raspberry Pi
Configuring your Raspberry Pi to use a dynamic DNS service such as DynDNS (or EasyDNS etc) is very simple and only needs a few configuration steps.
Firstly, I’m assuming that you’ve already set up your dynamic hostname with a service provider such as DynDNS or EasyDNS. In the past I’ve always used DynDNS but they are getting more restrictive and overly commercial, so if I were to make a recommendation for someone coming into this fresh, I’d go with EasyDNS.
SSH into your server (or open a Terminal window) and download something called the DDClient. DDClient is a very small utility that will update your hostname with your servers current external IP address automatically. You can ready more about the ddclient here: http://sourceforge.net/apps/trac/ddclient/
sudo apt-get install ddclient
You’ll see the pre-requisite packages being downloaded and installed (mainly Perl if you don’t have that installed yet), and then a simple configuration window is displayed.
I’ve selected my service of http://www.dyndns.com from the list, which then prompts me for my username. This is the username you log into your dyndns service, not your Raspberry Pi userID!
Next, you’re asked whether we should let the ddclient automatically find the external IP address of our Raspberry Pi server. If you have your Pi connected to your broadband router, then it will have been given an internal IP address, something like 192.168.0.10, or 10.10.10.1 for example. What we need to find is the actual IP address that your broadband router has been given by your ISP, this is your external IP address and the one that everything else on the Internet will use to find your server. (Later, we’ll configure the router to pass requests it receives onto your Raspberry Pi, but that’s in another post).
So let’s select ‘yes’ from this menu and let it work it’s magic.
Next, we’re asked whether we want to pick our host names from a list or to enter them manually. I like to select ‘From List’ here because it does a number of tests for us. Firstly, it’ll test that our username and password we entered above are correct, and secondly, it’ll test whether it can talk to your dynamic service provider and get the host names from it that you’ve already set up.
OK, so in the next image, we can see that the ddclient has managed to contact my dynamic IP address host and it has pulled down the three host names that I’ve already setup. I selected the first two in the list as they were the ones that I wanted to keep updated (yes, you can have more than one dynamic host name pointing to the same Rasperry Pi).
This next question always makes me smile, because it’s quite ‘retro’. Back in the day (when I was a lad etc..), PPP was mainly used by dial-up modems to connect to the internet rather than the always-on, wireless options we have today. This question is asking us if we basically connect with a modem, which I’ll assume you’re not. Select No and hit Enter.
Nearly there. Next we’re asked whether to run ddclient in the background every time we boot the Raspberry Pi, and we should select Yes here.
Now we’re running in the background automatically, you can specify how often ddclient contacts your dynamic host provider and updates your IP address. The default is 300 seconds, which is probably fine for most users, but adjust it if you feel the need to. I’d advise against setting it too low, as your dynamic service provider will have set an ‘abuse’ limit and you might get a slapped wrist for updating it too often – also, your IP address is unlikely to change very often anyway, probably when you reboot your router.
If you need to run through the configuration again, you can type
sudo dpkg-reconfigure ddclient
All that’s let is to test it out. If you haven’t already installed dnsutils (for command line tools like dig & nslookup), you can install them using the command:
sudo apt-get install dnsutils
Now type the name of your dynamic host into nslookup, like this. For example, if my dyndns hostname was called my-dynamic.hostname.com, then I’d type this.
Double check the ‘Address’ at the bottom against the external IP address that your broadband router has – they should be the same!
That’s it, now every time your broadband router gets a new IP address, your Raspberry Pi will automatically update your dynamic hostname to match it. You’ll now always be able to access your Raspberry Pi using a nice easy host-name instead of an IP address.
Next, you’ll need to install whatever server software that you’re planning to use, and then open the ports that the server needs on your broadband router (commonly called Port Forwarding).