Skip to content

Instantly share code, notes, and snippets.

@Stary2001
Created July 30, 2017 15:15
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 Stary2001/5451d8f0e708d532266b0254333d0230 to your computer and use it in GitHub Desktop.
Save Stary2001/5451d8f0e708d532266b0254333d0230 to your computer and use it in GitHub Desktop.
when you really want to be someone else just for a second
#!/bin/bash
function cleanup {
brctl delif 9net-bridge vethgw0
#ip netns exec blue ip link del vethgw1 type veth
ip link del vethgw0 type veth
ip netns del blue
}
trap cleanup EXIT
gw=$1
shift
ip netns add blue
ip link add vethgw0 type veth peer name vethgw1
ip link set vethgw0 up
ip link set vethgw1 netns blue
ip netns exec blue ip addr add 172.31.0.238/16 dev vethgw1
ip netns exec blue ip link set vethgw1 up
ip netns exec blue ip r add default via $gw
brctl addif 9net-bridge vethgw0
ip netns exec blue "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment