vm-start/ethernet_restreint/config_interface.sh

34 lines
742 B
Bash
Raw Normal View History

2024-02-14 00:04:11 +01:00
#!/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
bridge="br1"
add_bridge
bridge="br2"
add_bridge