How to Create Bridged Network Shared by KVM Host and GuestsSep 3rd 2021Words: 340
Background
I am trying to setup a KVM network where one of the guest running OpenWrt will be providing networking for other guests, as well as the host itself. The following figure shows the topology.
Steps
Create the bridge interface
To temporarily (non-persist over reboot) create a bridge interface:
1
ip link add br0 type bridge
To add the interface permanently, edit /etc/network/interface:
# bridge example static IP auto br0 iface br0 inet static address 192.168.1.100 network 192.168.1.0 netmask 255.255.255.0 # Include the following line if you want it to be the default route #gateway 192.168.1.1 broadcast 192.168.1.255 # bridge_ports argument is important else it fails on boot bridge_ports none bridge_stp off bridge_fd 0 bridge_maxwait 0
# bridge example DHCP auto br0 iface br0 inet dhcp # bridge_ports argument is important else it fails on boot bridge_ports none bridge_stp off bridge_fd 0 bridge_maxwait 0
KVM guests settings
OpenWrt
The bridge interface should be the first(ordered by PCI slot) interface of the OpenWrt, since it uses the first interface for LAN.