Opening a Raspberry Pi to the outside world

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 hostname.
  • 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][1] 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][2]

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.
Let’s check the current ip address first.

ifconfig | grep "inet "

There will be a number like 192.168.x.y
I always only change the y value. I don’t know if x can be changed safely

y to prevent ip conflicts with dynamic devices I always pick 100+ ip’s

sudo nano /boot/cmdline.txt

There will be a long line. At the end add ip=192.168.x.123