Never had the real need to access my home network from the outside but recently as working back at the office is becoming a reality, I just wanted to be able to check on my local deployments or be able to do minor tasks on my local network.
The option of setting up a standard VPN like OpenVPN is not viable, because my ISP is using CGNAT, like most these days.
What ZeroTier does is creating a virtual network on top of any network, so devices can communicate directly with each other. And this works with a CGNAT ISP.
ZeroTier has a free service up to 25 devices, which is great because my plan was to create a local ZT router at home, and access the remaining hosts through that host.
As I had a couple of Raspberry Pi’s with no usage, decided to use one of them to create the local ZT router.
Installing ZT and enabling local network routing
The first step is to install Raspberry Pi OS on an SD card and assign a fixed IP address on my local network. There is a ton of documentation on how to do this on the official Raspberry Pi documentation site.
After having the Pi running, it’s time to install ZeroTier.
There are many different networking configurations, in my case the simplest one is working. It’s the routing between ZeroTier and physical networks as described on this documentation.
Some things to consider here:
- When adding the managed route make sure to use all your local network address range (ie: 192.168.xxx.xxx/24) and the address used in the “via” field is the address assigned by ZeroTier to your router upon first connection (check the members section and Managed IPs column).
- Make sure to configure IP forwarding.
- Make sure to configure iptables and save the routes after reboot.
Having all these ready, you can connect to your router by installing the ZT client of your chosen OS and accessing either your router (the Raspberry PI) or any other host by IP address.
DNS resolution for your local network
While connecting by IP address is great, it’s not very functional, and in my case I have some local applications that I access using local domain names that I need to use when connecting through ZT to achieve the functionality I’m expecting.
So what I need is to have the same level of DNS resolution I have when at home. I’m locally using PiHole as a DNS resolver on my local network.
ZeroTier has a basic DNS resolution feature that when configured properly, is more than enough for my use case. Let’s keep in mind that ZT is actually meant to be used to connect to other devices in the ZT network, so this is kind of a workaround.
ZT can add a DNS resolver to your connected devices upon connection that instructs the device/host to use a specific DNS for an specific domain.
In my case all my local domains end with “.lan”, so by adding the value “lan” in the Search Domain field and my local DNS IP address in the Server Address field, I can achieve DNS resolution for all my local domains when connected to my home network using ZeroTier.
I also added all the hosts names as “host.lan” to be also able to connect to them using SSH.
I tested this solution on the road and works perfectly, still using the free ZT tier and connecting to any host I have at home.
Hope this article helps you resolve your connectivity needs, also let me know in the comments section if you are using ZeroTier in any other configurations and what’s your use case.