14 Apr 2016

Opening the Raspberry Pi 3 up to the Internet

OK, that`s enough set up and messing around. With our security set-up now, lets enable access to the Raspberry Pi 3 from anywhere in the world!


Unfortunately this is something that you may have to figure out some parts of yourself, it is highly unlikely we have the same network router and as such the steps I have to perform to open the Raspberry Pi 3 to the internet will be different to the steps you may have to take.

Saying that, the concept will be exactly the same and if you are really having trouble, Google will be your friend here. It should be relatively simple.


Even though our routers will be different I will show here how I set this up using my old router and then after that we will install a program called noip to allow us to create a URL that we can always use to connect to our Raspberry Pi 3 even if our home internet connections IP address changes.

Open Ports


The very first thing you are going to need to know is the password to access your routers settings. If you haven't changed this already, then you will find it on the bottom of your router. It is likely to be something like "changeme" or "admin" if you have not previously changed it. If you haven't changed it I recommend that you change it as soon as possible.

With the correct password navigate to your router using a browser, for me this is simply 192.168.0.1 in a browser and I am presented with the router log in page.

These screenshots are actually from an old router, but my new router is almost exactly the same, just faster!


Once you have logged in search for something like advanced settings and/or port forwarding,  I need to go to advanced settings, scroll down a bit and click on port forwarding.

Log in, choose advanced settings.


Scroll down to port forwarding and click on it.


Now in the port forwarding settings we need to add a rule for port 22 and port 80, I already have port 22 set-up, below are the settings I use for opening port 80.


I have chosen the service HTTP(TCP 80) and linked it to the Raspberry Pi 3`s IP address on my local network which in this case is 192.168.0.11. This means that if any traffic attempts to connect to my external IP on port 80 they will connected to port 80 on my Raspberry Pi 3. To add SSH is the same process choosing the correct port.

I click Add rule and now have both rules set-up for port 22 SSH and port 80 HTTP.


Now if we get our external IP address and type this address in to our browser we will be presented with the web page the Raspberry Pi 3 is currently serving, Likely the "hello world!" page we made if you were following along with the guide on this blog. Similarly if we use our external IP address in PuTTy to connect to our Raspberry Pi 3 via SSH it will connect and we can now use this from anywhere.


Our external IP address may change - it depends on your ISP, for me it is very irregular but on my old internet connection it was all the time. This meant the external IP address I knew when I left the house in the morning, may not be the same later on in the day and I couldn't access my Raspberry Pi while I was away from home. This kind of removes the whole point of this project if we cannot monitor and control our set-up while we are away from it.

A useful program/service we can use to get around changing IP addresses is noip, while not fool proof it is very useful and you get an actual URL to your Raspberry Pi 3 instead of having to remember the IP address....which helps.

Setting up noip


Firstly set-up a noip account, go to www.noip.com and create your self an account, the log in details will be required to install and get this working on the Raspberry Pi 3.

Once you are logged in to noip, click on Add host.



On the page that loads, assuming you are doing this on the same network as your Raspberry Pi 3, your IP address will be pre-populated. Otherwise enter the correct IP address.

On this page choose a hostname for your Raspberry Pi 3 and choose the URL extension from the drop down list, only some are free. Then scroll down and click the orange button Add host. 

This will create a URL made up of what ever you entered in to the part in the screenshot below that says "Enter a name here" and what ever you chose from the drop down list. So for example myraspberrypi.no-ip.me





After clicking Add host you will be shown a message saying the below, give it a minute and then navigate to the address you just created - you will be presented with your Raspberry Pi 3`s web page.



Now this is working, we need to set up noip on our Raspberry Pi 3 with our log in details to make sure our no-ip URL always points to the correct place.

Log in to the Raspberry Pi 3, I will navigate to a folder I created in the past using the command mkdir named Downloads, you can download this file to where ever you like. My command to move to my Downloads folder is below
cd Downloads/



To Download the required files for noip in to the current directory, in the terminal type
wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz



This will download the required files to the directory we are currently in, within the same directory in the terminal type
tar vzxf noip-duc-linux.tar.gz



This will extract the files we need from the downloaded file.


Now we need to install noip, we need to navigate to the extracted files,in the terminal type
cd noip-2.1.9-1


Now we need to install noip. in the terminal type
sudo make


Followed by
sudo make install



You will then be asked for the log in credentials for noip you created when you signed up to the website, enter these.


After this you will be asked for an update interval, this is in minutes, I have chosen 10 minutes. This is how often noip will check your IP and report it back to the service.



You will then be asked if you want to run something at a successful update, just press n and enter and our installation is complete.

To get noip working we need to type in to the terminal
sudo /usr/local/bin/noip2


Finally we want this to run at startup so we can always access our Raspberry Pi 3 no matter what. To get this to run at start up we need to edit one file.

In the terminal type
sudo nano /etc/rc.local


This will open the nano text editor, navigate down with the arrow keys until your cursor is in between fi and exit as in the screenshot below.


Here we need to enter /usr/local/bin/noip2 paste this in between fi and exit as in the screenshot below.


Press the Ctrl+x key combination followed by y and then enter to save your changes. Do a reboot and then in the terminal type the below to check if noip is running
sudo /usr/local/bin/noip2 -S

This will return something similar to below if it is running.


All done, now you will be able to connect to the Raspberry Pi 3 using your details both via SSH and directly to the web page using a browser from anywhere in the world!

Try it, go to the address you chose when adding a host in noip in your browser and you should see the web page your Raspberry Pi 3 is currently serving. The same address can now be used in PuTTY and any other programs you want to use, assuming you have opened the correct ports on your router.


All ran smoothly? any questions? Let me know in the comments below.

Thank you for reading this!

Show support for aquaponicpi and like the Facebook page! 
Click on the icon below to be taken to aquaponicpi on Facebook!
follow me on facebook











3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Initially this look was often called a random research and never a good way of defining men and women quickly and totally free.
    If your subject is female, she may have married or remarried.

    In this case it will be a good idea to know the maiden name of the person you’re looking for. It’s also good to know the married name(s) of your subject.USA Search People.

    ReplyDelete