Watching your pets with a Raspberry Pi and a mesh VPN

Viewing the Stream While Away

Now that you've got the camera and the video streams working from inside the local home network, it's time to set things up to view the pet cam while you're away from home. Of course, to test this out, you'll need access that is different from your local LAN. You might want to connect over your cell phone's hotspot for testing purposes.

Most home routers today provide network address translation, which means that the hosts on your home network are not addressable from the Internet. One way around this is to go to the admin settings of your home router, open a particular port, enable port forwarding on the router, and assign the forwarded port to the specific device (and port) that you would like to access remotely. However, this approach is ill-advised in today's security environment, because anyone with a port scanner can scan your router, find the open port, and use it to attack your network.

Thankfully, free services exist today that allow you to securely host your own VPN service and connect to your personal devices located behind firewalls and LAN routers. A traditional "old school" VPN would allow you, while at home, to remotely connect and access the computers and servers at your job. Using a self-hosted mesh VPN service (in this case, I'm using Tailscale [3]), I can be away from home at my job (or anywhere for that matter) and connect to the devices inside my home. Although Tailscale does not have a free software license, the company that maintains it provides a no-cost version for personal and hobby projects [4].

In order to set up a mesh VPN using Tailscale, all you need to do is install the free Tailscale client on each device that you want to participate in your personal VPN. Then log in to each client that you want to connect in the personal VPN.

The command to install Tailscale on the Raspberry Pi is:

curl -fsSL https://tailscale.com/install.sh | sh

Once you've connected your devices over your self-hosted mesh VPN, you can test the connectivity between devices by sending a ping request to your home PC while outside of your home network. If the ping works, the devices are connected.

The final step is to use your RTSP client app just as before, but this time, swap out the local-only IP address with the mesh VPN address of your Raspberry Pi. Voila, a self-hosted, mesh-VPN-enabled pet cam (Figure 4)!

Figure 4: I always wonder what he's up to while I'm away at work. This is the face of an innocent puppy staring at a sausage behind the Raspberry Pi.

Conclusion

This simple exercise illustrates the power of the Raspberry Pi as a practical tool for customizing your home environment. If you don't have a pet, you can easily adapt these techniques to watch your yard or observe wildlife. If you really get ambitious, you could even integrate a motion detector or set up a Pi-compatible infrared camera for night vision.

The Author

Bruce Hopkins is a technical writer, and is the author of the book Bluetooth for Java, by Apress Publishers.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • motionEyeOS

    Set up a professional video surveillance system armed with motionEyeOS and a Raspberry Pi.

  • PiCam Surveillance

    The new PiCam camera for the Raspberry Pi delivers image data with very little overhead, making it ideal for video surveillance applications. We find the bumps in the road you'll encounter and show you how to smooth them out with a few Linux commands and pipes.

  • A New Raspberry Pi Board

    The new board packs everything that you get in Raspberry Pi 3B+ in a smaller package.

  • Miniature Photography

    The combination of a web camera, Raspberry Pi, and simple software facilitates miniature tabletop photography.

  • Webcam Rescue

    If your new webcam doesn't work with the default software on your Linux system, try your luck with Guvcview or QtCAM.

comments powered by Disqus