Last active
January 17, 2020 02:46
-
-
Save qzaidi/b85a4e0b5137167a54a4701f23df13f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, setup the vpn on your pi-zero. For me, this entails | |
openfortinet -c vpn | |
# This will create a ppp0 interface, via which we want to allow tunneling to the whole network. | |
sysctl -w net.ipv4.ip_forward=1 | |
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE | |
iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT | |
iptables -A FORWARD -i ppp0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A INPUT -i wlan0 -p icmp -j ACCEPT | |
iptables -A INPUT -i wlan0 -p tcp --dport 22 -j ACCEPT | |
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -P FORWARD DROP | |
iptables -P INPUT DROP | |
iptables -L | |
# Since we want these commands to persist on reboot | |
apt-get install iptables-persistent | |
systemctl enable netfilter-persistent | |
# Afterwards, either set the pi as the default gateway on your network, or add specific routes like this | |
sudo route add -net 172.16.77.28 -gateway 192.168.0.10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment