feat(hack): Add script for venv-based virtual network
This commit is contained in:
27
hack/make-interfaces.sh
Executable file
27
hack/make-interfaces.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash -ex
|
||||||
|
|
||||||
|
# Create a venv-based virtual network for testing, consisting of:
|
||||||
|
#
|
||||||
|
# - venv0: Interface for the DHCP server (static address: 10.0.0.254/24)
|
||||||
|
# - venv1: Interface for DHCP client
|
||||||
|
# - br-dhcp: A bridge for communication between these interfaces
|
||||||
|
|
||||||
|
BR=br-dhcp
|
||||||
|
SERVERADDR="10.0.0.254/24"
|
||||||
|
|
||||||
|
brctl delbr $BR
|
||||||
|
brctl addbr $BR
|
||||||
|
|
||||||
|
for i in {0..1}; do
|
||||||
|
IFNAME="veth${i}"
|
||||||
|
PEERNAME="${IFNAME}s"
|
||||||
|
|
||||||
|
ip link add "$IFNAME" type veth peer name "$PEERNAME"
|
||||||
|
ip link set "$IFNAME" up
|
||||||
|
ip link set "$PEERNAME" up
|
||||||
|
|
||||||
|
brctl addif $BR "$PEERNAME"
|
||||||
|
done
|
||||||
|
|
||||||
|
ip addr add dev veth0 "$SERVERADDR"
|
||||||
|
ip link set "$BR" up
|
||||||
Reference in New Issue
Block a user