Skip to content

Instantly share code, notes, and snippets.

@zukka77
Created May 3, 2018 12:02
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 zukka77/d355d5b004f776e49c17db741a309218 to your computer and use it in GitHub Desktop.
Save zukka77/d355d5b004f776e49c17db741a309218 to your computer and use it in GitHub Desktop.
ip netns add zukns
ip link add veth0 type veth peer name veth1
ip link set veth1 netns zukns
ip a add 169.254.69.68/31 dev veth0
ip link set veth0 up
ip netns exec zukns ip a add 169.254.69.69/31 dev veth1
ip netns exec zukns ip link set veth1 up
ip netns exec zukns ip r add default via 169.254.69.68
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -s 169.254.69.69 -j MASQUERADE
iptables -I FORWARD -s 169.254.69.69 -j ACCEPT
iptables -I FORWARD -m state --state related,established -j ACCEPT
ip netns exec zukns /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment