Add a network bridge to your KVM/qemu Virtual Machines.

I was used to SetUp VirtualBox Guests with a Network Bridge in order to have bidirectional access from Host to Guest or Guest to Host. In the simpler NAT mode, I was only able to ssh from my Host to Guest but not ssh from Guest to Host.

Most of the time I used the Bridge Network Mode in Virtual Box, then I switched from Virtual Box to KVM/qemu/libvirtd. Thanks to virt-manager or Gnome Boxes it was relatively easy to use those tools instead of VirtualBox.

When using virt-manager, you have the option to setup the network mode from GUI. Unfortunately there is not an option in drop box to select Network bridge. Instead we have to create the bridge from command line.

Use Network Manager Client to create “br0” bridge interface, in my case the physical Ethernet network interface (From a ThinkPad docking) is: enp0s20f0u2u1i5.

 sudo nmcli con add ifname br0 type bridge con-name br0                                                                                  
sudo nmcli con add type bridge-slave ifname enp0s20f0u2u1i5 master br0                                                                  

Bring down physical Ethernet interface and bring up bridge br0.

sudo nmcli con down "Wired connection 1"                                                                                                 
sudo nmcli connection up br0

Setup xml file to be used by virsh:

Use virsh:

sudo virsh net-define ./kvm_br0.xml                                                                                                      
sudo virsh net-start br0                                                                                                      
sudo virsh net-autostart br0                                                                                                             

You will see bridge br0 in drop box from virt-manager

My host now has IP Address

My KVM guess has IP Address Then, thanks to bridge I can ssh from Ubuntu Guest to my Fedora Host!

You can modify bridge IP address manually as well. For instance, use:

nmcli connection modify br0 ipv4.addresses '192.168.X.X/24'
nmcli connection modify br0 ipv4.gateway '192.168.X.254'
nmcli connection modify br0 ipv4.dns '192.168.X.254'
nmcli connection modify br0 ipv4.method manual

Leave a Reply

Your email address will not be published. Required fields are marked *