This part is a bit tricky. Because it’s depending on third parties. And they all work a bit different. The big stokes are the same for everyone but the how will differ a bit. This step can also be done later.
Opening the router to the outside world.
You need to login into your modem which your ISP provided to you. How to do that might differ per modem. But usually it will be an ip which start with 192.168.. To help you get started. A few pointers.
- Inspect the modem. Look for passwords and model type.
- Google the modem type, this will help with the ip and maybe the default login credentials.
- Some still have default passwords, instead of random generated.
- Call your ISP, it’s there modem they should be able to help.
Once you are in the modem settings we are going to do a thing called port-forwarding. I had a lot of problems figuring this out. Because of that I’m going to refer you else where. Keep in mind the following.
- You will need to forward it to the hostname or the internal IP used by the Pi. If you need the IP see below to give a static IP. The hostname you can get with
- The ports we are talking about should be 80 for http and 443 for https.
- If you want too login to ssh remote secure your remote and forward port 22 for ssh.
- You might need something called “TCP”
- I needed to fiddle with a setting “DMZ Host”network
- If you are struggling google port-forwarding with your modem
As I said this is really not my piece of pi, so here is a better guide: HowToGeek guide
Adding a domain name
First you will need to register a domain name. There are a lot of these registrars as they are called. I’m not going to recommend any because I registered all my domains at a Dutch company. One registered you will need to add a DNS A-record that will point to your home IP.
You can get your home network IP with the following command:
wget http://ipinfo.io/ip --timeout=3 --tries=1 -qO -
To test if your url is working run:
ping example.com -c 5
It should return something like this, with your home IP:
5 packets transmitted, 5 received, 0% packet loss, time 1000ms
Giving the raspberry a static IP
Your modem probably needs a ip for port-forwarding. You will want a static IP so you don’t need to change the IP after a power outage or whatever. First we need to collect some IP addresses. Be sure to make note them while collecting them.
The interesting line is the second. Note all 3 of those. The first one is the one I’m changing in this example.
inet addr:192.168.2.10 Bcast:192.168.2.255 Mask:255.255.255.0
Also note the destination ‘192.168.2.0’ and Gateway ‘192.168.2.254’.
I will change the current
192.168.2.90 The last digit can be changed to anything between from 0 to 255. But It is better to use a big number. Lets say we would change it to ‘192.168.2.1’. But your desktop uses that same IP address. Then neither will be able to connect. So change it to a higher number, which is less likely to be used.
We now have all information, let’s apply the changes.
sudo nano /etc/network/interfaces
This will open the file
Switch these lines
# in front of the line:
iface eth0 inet manual
Below that add:
iface eth0 inet static
My final interfaces file:
Now reboot and login with the new IP address
- If for some reason you can’t login, try the old IP.
- Go directly to the Pi hookup a screen and keyboard and check the IP
- Else open the interfaces file again directly on the pi itself.
sudo nano /etc/network/interfaces
And undo all changes.