Chapter 8 Access your Pi from anywhere
ET wants to phone home..
More Raspberry Pi.....
This is not for the faint of heart.... But, if you have made it this far, you
should be fairly Pi Fluent and comfortable with the previous topics.
OK, so you have been having fun making Webcams! 6 Webcams! Mittens has no
place in the house to hide the catnip ball that we can't see! So, you have read the
earlier posts and set up fixed IP addresses. Cam 1 is 192.168.1.51, Cam 2 is
192.168.1.52, etc. You can put that in your browser, click "HTML" and see your
Mittens Live! But you are in your house, on your "Local Area Network", or LAN. Then
reality hits.... You have to go back to work! How do I keep track of Mittens?????
Toto, you're not in Kansas any more.... The other side of the router is called the
"WAN", or Wide Area Network. You can get there from here. It gets a little
complicated, but let's try to break in down to simpler terms.
Enter the term Ports. When you access your camera with a browser, you type
in 192.168.1.51. But your browser assumes 192.168.1.51:80. It is assuming port 80
for you. When you log in from a terminal, SSH assumes port 22. But, that is on the
LAN side. When you are on the WAN side, your provider gives your house it's own IP
address, say 18.104.22.168. (Showmyip.com) So, you put 22.214.171.124 into your
browser. It tries to bring up the web page for your router, but has no clue you
have 6 webcams on the same port. And, the web page for your routed is turned off
from default from the outside "WAN". Port numbers are expected for specific
purposes, but CAN be played with. Enter "PORT FORWARDING".
You can put 126.96.36.199:3011 into your browser. It is looking for port 3011
somewhere in your house on your LAN. In your router, which all are different, you
search for "Port Forwarding". You forward port 3011 to port 80 (The normal web page
port), at 192.168.1.51, or Cam 1. You also port 3012 to port 80 at 192.168.1.52.
So, now, you are at the coffee shop and in your browser, you enter
188.8.131.52:3011. Up comes Mittens on Cam 1! Enter 184.108.40.206:3012. There she
is om Cam 2! You have taken specific port numbers and assigned them to specific
functions on your internal network. That is how you access your specific Pi from
the outside. Forward port 3111 to port 22 (the normal SSH port), at 192.168.1.51
and now you can remotely log into Cam 1 with SSH from the outside. Just connect
with 220.127.116.11:3111. Obviously, you need to input your addresses for your
So, knowing the IP address for your modem in your house, and setting up
specific unique ports for each Pi and forwarding them to the PI at the expected
port, you can select a specific function at a specific Pi by a unique port number
To reiterate, all of your Pi's are looking to respond to port 80 with a web
page with live video. You enter 18.104.22.168 into your browser. Not good enough.
Enter 22.214.171.124:3011. Your router translates that to 192.168.1.51:80 by your
configuration. Cam 1 wakes up seeing port 80 activity, and sends you live video.
Likewise, 126.96.36.199:3012 wakes up Cam 2. Port forwarding is like "Press 1 for
parts, press 2 for service, press 3 for sales....." You map out a port to cam 1 for
video, another port for remote login with SSH, two more ports for Cam 2, two more
for Cam3, etc. You will eventually have a list of ports for each pi for video, for
ssh, for telnet, etc.
OK, so it's more like Press 1 for Ford parts, press 2 for Ford service, press
3 for Ford sales, press 4 for GM parts, press 5 for GM service, press 6 for GM
sales, press 7 for Toyota parts, press 8 for Toyota service....... you get the
picture. Port numbers ... extension numbers.... similar concept.
So, once you know your ip (Showmyip.com) for your modem in your house,
you can configure your router to use port numbers to access different functions
from different Pi's. COOL! You can get back to your Cameras from the Smart phone,
the tablet at the coffee shop, whatever.....
THEN... SPECTRUM CHANGES YOUR IP! Now, you have to go to 188.8.131.52:3011
to see Mittens on Cam 1. So, you have to go back home and bring up Showmyip.com,
or whatever, to see what your new IP address is. Then update your bookmarks to point
to the new link. But, you are away on vacation. You can't check your IP because you
aren't home. Now what???? Enter DDNS. Remember DNS from an earlier post?
It was like a Phone Book of IP addresses. Sears was 184.108.40.206 and
Macys was 220.127.116.11. But, you type in Sears.com and it automatically takes you to
18.104.22.168. But, how do they know me or where I am IP wise? THEY DON'T!!!
Places sell custom domain names, and publish them in a "Phone Book". So, Macys pays
to register the name Macys and have 22.214.171.124 published in the book as well.
But, your number may change. Enter DYNAMIC DNS. Your IP address of your modem
is monitored. If it changes, your number in the "Phone Book" is updated as well. That
method varies, depending on their software. I use Namecheap.com. There are many others.
My domain costs about $20 per year and includes Dynamic DNS. There are several ways
to implement DDNS. I chose to download Open WRT software to replace my router's
software. It gives me a lot more functions than the stock software. It also allows me to install
software that monitors my IP address and update Namecheap.com when it changes.
They all work similarly, some having protocols imbedded in the router software.
So, is it worth it?, Your choice. If you are happy typing in 126.96.36.199
and searching for the new number when it changes, you are good. If you would prefer
to use "MyCallSign".com and have it automatically update for about $20 per year,
you can do that too. Instructions for that depend on the provider. You will need to
read their help files or ask for support to get it running on your system. It is
different for every router and every provider. It is a lot of work, but when you
have it set up, you can be anywhere in the world, type in K2XYZ.com:3011 and see
Mittens chasing that catnip ball! Maybe Mittens should read 1984.....
Here is the above as a downloadable pdf.
Jim Albrecht K2BHM