During the configuration of KVM (Kernel Based Virtual Machine) you will need to create a network bridge adapter so that your virtual machine can be connected directly to the host network and vice versa. This guide will show how to do that.

Required Modules:

Centos 7 comes with the bridge modules loaded by default. We can verify this by using the command modinfo as shown below.

[[email protected] network-scripts]# modinfo bridge
filename:       /lib/modules/4.20.6-200.fc29.x86_64/kernel/net/bridge/bridge.ko.xz
alias:          rtnl-link-bridge
version:        2.3
license:        GPL
srcversion:     8568C7B4D680D54EEDAADD6
depends:        stp,llc
retpoline:      Y
intree:         Y
name:           bridge
vermagic:       4.20.6-200.fc29.x86_64 SMP mod_unload 
sig_id:         PKCS#7
sig_hashalgo:   md4

If you do not see output then the module is not loaded and you have to load it as follows:

# modprobe --first-time bridge

Also ensure you have bridge-utils.

yum install bridge-utils -y

Create the network bridge using the following commands.

In this example, I am going to be migrating the interface "enp3s0" to a new bridge "br0".

Make sure to replace enp3s0 with the name of your interface device
INTERFACE=enp3s0 #Update this to the name of your device
BRIDGE=br0 #The bridge name. 
sudo nmcli con add type bridge ifname  $BRIDGE
sudo nmcli con mod bridge-br0 bridge.stp no
sudo nmcli con add type bridge-slave ifname ${INTERFACE} master $BRIDGE
In the example above where we created for device enp3s0, you should find two new files in /etc/sysconfig/network-scripts/ called ifcfg-bridge-br0 ifcfg-bridge-slave-enp3s0

Finally set br0 bridge.stp to no otherwise you will not be able to ssh into your virtual machines from the hsot

nmcli connection modify br0 bridge.stp no