Create network bridge for guest VM on same subnet as host using QEMU/KVM virt-manager

After a lot of trial and error I have figured it out. The solution is as follows:
Disconnect or turn off (the best way is to delete) the existing wired network connection. This is very important so the existing connection doesn’t interfere with the setup.
The setup is by using nmcli (command-line tool for controlling NetworkManager) and brctl (ethernet bridge administration)

sudo nmcli con show
NAME    UUID                                  TYPE    DEVICE
virbr0  c42932ae-be14-4b8e-9c70-69868d093483  bridge  virbr0

sudo brctl show
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.52540066413b       yes

In this case we are ignoring virbr0 as it is already created by VirtualBox I think.

Add a new bridge interface on host machine:

sudo nmcli con add type bridge ifname br0
Connection 'bridge-br0' (0ac8ba53-3ae8-4241-b464-ec0671aa0239) successfully added.

ip a
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d8:bb:c1:47:1b:bb brd ff:ff:ff:ff:ff:ff   <---
    altname enp5s0
6: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 66:bb:79:6b:bb:67 brd ff:ff:ff:ff:ff:ff   <---

Attach the newly added bridge br0 to physical interface on host, in this case eth1 :

sudo nmcli con add type bridge-slave ifname eth1 master br0
Connection 'bridge-slave-eth1' (4696cbda-1002-469c-9893-c085e726ebd5) successfully added.
sudo nmcli con show
NAME               UUID                                  TYPE      DEVICE 
bridge-br0         0ac8ba53-3ae8-4241-b464-ec0671aa0239  bridge    br0   <---
bridge-slave-eth1  4696cbda-1002-469c-9893-c085e726ebd5  ethernet  eth1   <---
virbr0             c42932ae-be14-4b8e-9c70-69868d093483  bridge    virbr0

ip a
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether d8:bb:c1:47:1b:bb brd ff:ff:ff:ff:ff:ff   <---
    altname enp5s0
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d8:bb:c1:47:1b:bb brd ff:ff:ff:ff:ff:ff   <---
    inet 192.168.0.10/24 brd 192.168.0.255 scope global dynamic noprefixroute br0
       valid_lft 86071sec preferred_lft 86071sec
    inet6 fe80::291e:4838:6d3b:6620/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Notice that br0 is now attached to the physical interface eth1. This will also reflect in ‘brctl show’ :

sudo brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.d8bbc1471bdb       yes             eth1   <---
virbr0          8000.52540066413b       yes

Configure the Virtual Machine Manager (QEMU/KVM) to use Network Source as ‘Bridge device’ and ‘Device name’: br0

1 Like