diff --git a/scripts/setup_network.sh b/scripts/setup_network.sh index 4cb37be..75b6a79 100755 --- a/scripts/setup_network.sh +++ b/scripts/setup_network.sh @@ -6,33 +6,51 @@ set -ex +# Create veth pairs ip l add p0 type veth peer p1 ip l add p2 type veth peer p3 ip l add p4 type veth peer p5 +ip l add p6 type veth peer p7 +# Create bridge ip l add mycelium-br type bridge +# Add 1 part of every veth pair in the bridge ip l set p1 master mycelium-br ip l set p3 master mycelium-br ip l set p5 master mycelium-br +ip l set p7 master mycelium-br +# Add network namespaces ip netns add net1 ip netns add net2 +ip netns add net3 +# Enable loopback devices in network namespaces ip -n net1 l set lo up ip -n net2 l set lo up +ip -n net3 l set lo up +# Add 1 veth end to every network namespace ip l set p2 netns net1 ip l set p4 netns net2 +ip l set p6 netns net3 +# Set underlay IP addresses on the veth parts which are not in the bridge ip a add 10.0.2.1/24 dev p0 ip -n net1 a add 10.0.2.2/24 dev p2 ip -n net2 a add 10.0.2.3/24 dev p4 +ip -n net2 a add 10.0.2.4/24 dev p4 +# Set all veth interface to up ip l set p0 up ip l set p1 up ip -n net1 l set p2 up ip l set p3 up ip -n net2 l set p4 up ip l set p5 up +ip -n net3 l set p6 up +ip l set p7 up + +# Set bridge as up ip l set mycelium-br up