Skip to content

Instantly share code, notes, and snippets.

@nati
Created December 10, 2015 18:34
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 nati/71765ee6c5b8d5433a21 to your computer and use it in GitHub Desktop.
Save nati/71765ee6c5b8d5433a21 to your computer and use it in GitHub Desktop.
#!/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