Gnome boxes bridge

Hi all. I use the Linux Rocky 8 operating system; the Gnome Boxes virtualization package is installed by default, the program is simple and convenient. (I don’t know about anyone, but I like it). But there is one small problem. Bridge. My host computer (physical machine) has an IP address of 192.168.1.100. There are also two computers on this subnet with addresses 192.168.1.101 and 192.168.1.102. On host address 1.100, I installed three virtual machines, let’s call them PC1, PC2, and PC3. Accordingly, inside the virtual machine, they received the addresses 192.168.122.1, 122.2 and 122.3. Virtual machines are accessible only from the host machine (192.168.1.100) from other machines (192.168.1.101 and 1.102) virtual machines are not available. Question: How can I create a bridge so that virtual machines (PC1, PC2 and PC3) get addresses from my real subnet (For example 192.168.1.110, 1.111 and 1.112)?

One way to do it is to use network manager to create a bridge that is using the physical nic of your host system. After that, libvirt should see the bridge interface and it should be an option for the virtual machines.

# replace eno1 with whatever your interface name is
nmcli con delete eno1
# or...
nmcli con delete 'Wired connection 1'
nmcli con add type bridge ifname br1000 con-name br1000
nmcli con add type bridge-slave ifname eno1 master br1000
nmcli con up br1000

If memory serves, a bridged interface and DHCP don’t get along. Connected machines to the bridge (your libvirt vm’s) will be able to get addresses just fine. If your br1000 interface isn’t getting an IP from your DHCP, set it manually.

nmcli con mod br1000 ipv4.addresses 192.168.1.100/24
nmcli con mod br1000 ipv4.gateway 192.168.1.1
nmcli con mod br1000 ipv4.method manual
nmcli con up br1000

if libvirt doesn’t see the bridge right away, you’ll need to add it:

cat > /tmp/br1000.xml <<EOF
<network>
  <name>br1000</name>
  <forward mode="bridge"/>
  <bridge name="br1000" />
</network>
EOF

virsh net-define /tmp/br1000.xml
virsh net-start br1000
virsh net-autostart br1000
1 Like

Thanks for your reply. I’ll definitely try tomorrow.

I have not noticed that and I do have bridges on ‘auto’ on EL8 (and EL7 & EL9 too).

Another example of the nmcli commands is in man nmcli-examples.
One can set most (all?) options of connection in one command:

nmcli con add type bridge ifname br1000 con-name br1000 bridge.stp no ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns what-you-have-now

The options are described in man nm-settings.

I’d rather stop the VM guests and systemctl restart libvirtd
I’ve never had a need to define a libvirt network for bridges.

One can set most (all?) options of connection in one command

Yes, you can. But for explanation purposes for some users, it is simply easier to read with multiple commands.

1 Like