Created
December 10, 2015 18:34
-
-
Save nati/71765ee6c5b8d5433a21 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
set -x | |
brctl addbr br1 | |
ip link set dev br1 up | |
function makeenv { | |
local id=$1 | |
local ip=$2 | |
echo "create env $id with $ip" | |
ip netns add ns_$id | |
ip link add veth_$id type veth peer name veth_p$id | |
ip link set veth_$id netns ns_$id | |
brctl addif br1 veth_p$id | |
ip link set dev veth_p$id up | |
ip netns exec ns_$id ifconfig veth_$id up $ip | |
ip netns exec ns_$id ifconfig lo up | |
} | |
makeenv gohan1 10.0.0.1/24 | |
makeenv gohan2 10.0.0.2/24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment