Skip to content

Instantly share code, notes, and snippets.

@dz0ny
Last active December 28, 2017 13:46
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 dz0ny/22db8e4d7bee5d2450b8dd45b8075fae to your computer and use it in GitHub Desktop.
Save dz0ny/22db8e4d7bee5d2450b8dd45b8075fae to your computer and use it in GitHub Desktop.
dev="vpn-swan"
gw=$(ip a show $dev| grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
ip rule del from 10.10.10.0/24
ip rule add from 10.10.10.0/24 priority 10 table 100
ip route add 10.10.10.0/24 dev $dev table 100
ip route add default via $gw dev $dev table 100
ip route flush cache
iptables -I FORWARD -o $dev -j ACCEPT
iptables -t nat -I POSTROUTING -o $dev -j MASQUERADE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment