34 lines
782 B
Bash
Executable file
34 lines
782 B
Bash
Executable file
#!/bin/bash
|
|
|
|
add_bridge() {
|
|
echo "add bridge interface ${bridge}"
|
|
ip link add ${bridge} type bridge
|
|
|
|
# authorise qemu to use as interface ${bridge} as bridge
|
|
if cat /etc/qemu/bridge.conf | grep -q "${bridge}"
|
|
then
|
|
echo "bridge already authorised by qemu"
|
|
else
|
|
echo "allow ${bridge}" | tee -a /etc/qemu/bridge.conf
|
|
echo "entry added to /etc/qemu/bridge.conf"
|
|
fi
|
|
|
|
echo "activate bridge ${bridge}"
|
|
ip link set dev ${bridge} up
|
|
}
|
|
|
|
|
|
ip link add br0 type bridge
|
|
ip link set dev tap0 master br0
|
|
ip address delete 10.0.2.100/24 dev tap0
|
|
ip address add 10.0.2.100/24 dev br0
|
|
ip link set dev br0 up
|
|
ip route add default via 10.0.2.0 dev br0
|
|
ip route add 10.10.0.0/24 via 10.0.2.31
|
|
|
|
bridge="br1"
|
|
add_bridge
|
|
|
|
bridge="br2"
|
|
add_bridge
|
|
|