Created
January 20, 2014 15:02
-
-
Save teemow/8521357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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