Skip to content

Instantly share code, notes, and snippets.

@DeadSix27
Created February 27, 2018 00:00
Show Gist options
  • Select an option

  • Save DeadSix27/e7e611ad26d1df722cb3fa214eb04538 to your computer and use it in GitHub Desktop.

Select an option

Save DeadSix27/e7e611ad26d1df722cb3fa214eb04538 to your computer and use it in GitHub Desktop.
ip netns add vpn
ip netns exec vpn ip addr add 127.0.0.1/8 dev lo
ip netns exec vpn ip link set lo up
ip link add vpn0 type veth peer name vpn1
ip link set vpn0 up
ip link set vpn1 netns vpn up
ip addr add 10.200.200.1/24 dev vpn0
ip netns exec vpn ip addr add 10.200.200.2/24 dev vpn1
ip netns exec vpn ip route add default via 10.200.200.1 dev vpn1
iptables -A INPUT \! -i vpn0 -s 10.200.200.0/24 -j DROP
iptables -t nat -A POSTROUTING -s 10.200.200.0/24 -o en+ -j MASQUERADE
sysctl -q net.ipv4.ip_forward=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment