No matter which services your Raspberry Pi is running you will want it to have a static address for global access, which is done by setting up a dynamic DNS service.
In this guide I describe the steps you need to complete in order to set up a free dynamic DNS service on your raspberry Pi (yes, this also works for Raspberry Pi 2), so that you no longer have to worry about whether your external IP address changes once in a while. Whenever it changes, the dynamic DNS makes sure that your chosen website URL will always resolve to the current external IP of your Raspberry Pi.
As I set up my Raspberry Pi Mumble server, I needed to have a static web address for everyone else to access it. It would be very troublesome having to tell everyone about it every time my dynamic IP changed.
After a bit of research I decided to go with the free service provided by dnsdynamic.org, as it is both free to use and easy to set up.
Step by step guide
It should work just as well with other linux systems than Raspbian on the Raspberry Pi.
- Create a user profile at the dnsdynamic website.
- Choose to “add a new domain” when logged in on the dnsdynamic website.
- Open a terminal on your Raspberry Pi and install the update service:
sudo apt-get install ddclient
- If you are presented with a configuration wizard, just go through it and put in some random text.
(We will overwrite this in the configuration file anyway)
- Edit the configuration file
/etc/ddclient.confand replace everything in it with this:
# Configuration file for ddclient generated by debconf
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.
use=web, web=myip.dnsdynamic.com # get ip from server.
server=www.dnsdynamic.org # default server
login=YOUR-LOGIN # your login
password=YOUR-PASSWORD # your password
- Edit the three placeholders YOUR-LOGIN, YOUR-PASSWORD and YOUR-DOMAIN and replace them with your own.
- Save the changes made to the config file, and restart the Raspberry Pi.
- Remember to configure your router to forward the necessary ports to your Raspberry Pi.
(port 80 for web server, 21 for ftp, 64738 for default mumble, etc.)
If everything is working as intended, you should see the global IP of your Raspberry Pi automatically set on the dnsdynamic website, under Manage -> Edit domains.
Now you can access your Raspberry Pi services at the domain name you chose with dnsdynamic.org instead of your global IP address. Should your global IP change, the daemon will automatically detect this and make the domain point to the new global IP instead. The users will never know that the IP has changed, since they only see and use the domain name.
If you have another domain you want to use instead of the ones provided by dnsdynamic, simply configure the DNS of your other domain to do a CNAME forward to your dnsdynamic domain.
Checking for IP changes every 60 seconds may be a bit overkill in some cases. You can change the
daemon=60 to eg.
ddclient.conf to check for IP changes every 5 minutes instead.