Skip to content

Instantly share code, notes, and snippets.

@teemow
Created January 20, 2014 15: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 teemow/8521357 to your computer and use it in GitHub Desktop.
Save teemow/8521357 to your computer and use it in GitHub Desktop.
#!/bin/sh
ns=my-namespace
in_ns="ip netns exec $ns"
# set up namespace
ip netns add $ns
$in_ns ip link set dev lo up
# add veth interfaces and move one to the namespace
ip link add veth0 type veth peer name veth1
ip link set veth1 netns $ns
# add ip addresses to the interfaces
ip addr add 10.0.0.1/24 dev veth0
$in_ns ip addr add 10.0.0.2/24 dev veth1
# bring up interfaces
ip link set dev veth0 up
$in_ns ip link set dev veth1 up
# add a bridge for the lxc container in the namespace
$in_ns brctl addbr br-lxc
$in_ns brctl addif br-lxc veth1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment