Route all traffic through zerotier running on raspberry pi

Hello, I have been running zerotier successfully for some time on a network of 9 devices (8 RPi and one android phone). I now would like to route all my traffic through zerotier when I am away. I have followed the instructions on this article “https://zerotier.atlassian.net/wiki/spaces/SD/pages/7110693/Overriding+Default+Route+Full+Tunnel+Mode” and followed through this topic “How can I route all internet traffic through Zerotier? - #5 by AleXSR700”.

I have added a managed route in my Zerotier web gui where all traffic should go through my RPi running Zerotier (0.0.0.0/0 through 192.168.195.250). I also have a LAN managed route of 192.168.195.0/24.

In particular, to enable the routing through zerotier, I:

  1. enabled port forwarding on the /etc/sysctl.conf file by uncommenting the net.ipv4.ip_forward=1 line
  2. I changed the /etc/iptables/rules.v4 file to the following

*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUARADE
COMMIT

*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
-A FORWARD -i 192.168.195.0/24 -o 0.0.0.0/0 -j ACCEPT
-A FORWARD -i 0.0.0.0/0 -0 192.168.195.0/0 -m state --state RELATED,ESTABLISHED
:OUTPUT ACCEPT [0:0]
COMMIT

192.168.195.0 is the zerotier route in my network, but I am not sure if the 0.0.0.0/0 is correct in this case or if it should be my internal ip address (ie 192.168.1.0) or sth entirely different

After applying these changes and rebooting my RapPi Iogged in my android app and under configuration ticked the "Route all traffic through Zero Tier. However, this does not seem to work.

Would you be able to help pls?

I changed the /etc/iptables/rules.v4 file to the following:

*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUARADE
COMMIT

*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
-A FORWARD -i ztxxxxxxxxxx -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o ztxxxxxxxxxx -m state --state RELATED,ESTABLISHED -j ACCEPT
:OUTPUT ACCEPT [0:0]
COMMIT

That solved my issue and I can now route all internet traffic through zerotier.

Very good instructions included here: https://harivemula.com/2021/09/18/routing-all-traffic-through-home-with-zerotier-on-travel/ - just in case anyone faces similar issues

This topic was automatically closed after 30 days. New replies are no longer allowed.