Skip to content

Instantly share code, notes, and snippets.

@foxel
Last active September 1, 2015 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxel/e4b4d6659a03cc77d744 to your computer and use it in GitHub Desktop.
Save foxel/e4b4d6659a03cc77d744 to your computer and use it in GitHub Desktop.
VPN share
#!/bin/sh
# Share the VPN connection with other machines on the local net.
# The assumption here is that the VPN networks are 10.10.0.0/24 and 10.10.1.0/24.
if [ `id -u` -ne 0 ] ; then
echo "You are not root. Rerunning with sudo..."
sudo bash $0
else
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth2 -d 10.10.0.0/24 -j ACCEPT
iptables -A FORWARD -i eth2 -d 10.10.1.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sysctl net.netfilter.nf_conntrack_acct=1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment