Raspberry Pi Dynamic DNS

In this guide I will take you through on how to set up Raspberry Pi port forwarding on the router and also setting up Raspberry Pi Dynamic DNS. Both of these compliment each other but port forwarding is very important if you want web applications accessible over the internet.


I have prepared a video below that takes you through everything you need to know about setting up both of these. If you enjoy then please subscribe so you can stay up to date on all the latest awesome Raspberry Pi projects, guides and much more.

Setting Up Raspberry Pi Port Forwarding

Raspberry Pi port forwarding is a way we are able allow for external access to the Pi. In order to do this we will need to change some settings on the router.

All routers are different but I will try and make this as generic as possible however there could still be a lot of differences between these instructions and your router. The router I am using for this tutorial is the TP Link AC1750 wireless dual band gigabit router.

  1. On a computer that is connected to the local network connect to the router admin page via the a web browser.
    A router IP typically is 192.168.1.1 or 192.168.1.254
  2. Enter the username and password for the router. By default this is typically admin & admin.
  3. In the router admin page head to forwarding->virtual server.
  4. On this page enter the following
    • Service Port: This is the external port
    • IP Address: This is the IP of the Pi
    • Internal Port: Set this to Pi’s application port. (A web server runs on port 80 for example)
    • Protocol: Set this to ALL unless specified
    • Status: Set this to enabled
  5. These settings will route traffic destined for the port specified to the port on the Raspberry Pi.
  6. You should now be able to connect to the application on the Raspberry Pi outside your network.

The best way to check if you have port forwarded correctly would be to either get a friend or go somewhere outside your local network.

Below is an example of setting up access for a web server that is running on port 80 with the Raspberry Pi having an IP of 192.168.1.103.

Raspberry Pi Port Forwarding

 

Troubleshooting

There are a few issues that might occur when attempting to setup your Pi for external access. Below are just a few issues you might come into when setting up Raspberry Pi port forwarding.

  • Double check your router settings and confirm they are correct.
  • Check that your external IP hasn’t changed. ISP’s will provide you with a dynamic IP rather than a static IP.
  • Restarting the router might clear problems.
  • Restarting the Raspberry Pi might also clear any problems.

Setting up Raspberry Pi Dynamic DNS

If your ISP supplies you with a dynamic IP (An IP that changes often) then it will probably be worth setting up the Raspberry Pi dynamic DNS (Sometimes Routers has this feature in them). This means you will always be able to connect to the application on the Pi even if your external IP changes.

  1. First you will need to create an account over at No-IP (Make sure “create a hostname later” is unticked)
  2. Now on the Raspberry Pi enter the following commands
    sudo bash
    cd /usr/local/src/
    wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
    tar xf noip-duc-linux.tar.gz
    cd noip-2.1.9-1/
    make install
    • You will be now presented with a few settings you will need to set.
    • Enter the email and password for the account you wish to connect the Pi to.
    • Next set the update interval with the default being 30 minutes. (This checks to see if the IP has changed)
    • You can now also set something to run whenever the IP updates.
      Raspberry Pi No IP
  3. Now add a new line into the rc.local file just before the last line exit 0 this ensures that no-ip will automatically start on reboot.To do this enter the following commands:
nano /etc/rc.local
  1. Enter the following line right above the exit 0 line.
    /usr/local/bin/noip2
  2. Use CTRL+X to exit (Make sure you save)
  3. You can start no ip with the following command:
sudo /usr/local/bin/noip2
  1. Check the status with the following command:
sudo /usr/local/bin/noip2 -S
  1. You can close it using the following command. Replace pid with the pid from the –S command.
    sudo /usr/local/bin/noip2 -K 'pid'
  2. You’re able to recreate the default config file if required by entering the following command:
    sudo /usr/local/bin/noip2 -C

Now you should have a Raspberry Pi dynamic DNS server setup and be able to connect with a domain name rather than an IP. This name will remain the same even if your IP address changes. This means you will be always able to connect to the Pi or other home network devices without needing to find out your new external IP.

If you’re looking for a project that requires access to the internet then you should check out either the Raspberry Pi Web Server, mumble server or even the  webcam server.
 

Share This!
The Raspberry Pi Crash Course

The Raspberry Pi Crash Course

Enter your email address below to get the

Raspberry Pi crash course delivered straight to your inbox

Please check your inbox for a confirmation email!