Centos 7 – bridge for KVM

nicubunu-RPG-map-symbols-stone-bridge-100pxI got a machine on which I wanted to try Centos 7 and KVM virtualization. As usual, I had to search for how to do a network bridge as it’s been quite long since I did it last time (on Centos 6). So these are the basic steps. First, dont’t forget to install bridge-utils while installing the KVM-related packages:

yum install qemu-kvm libvirt virt-install bridge-utils ifconfig bind-utils

Now, this was the default config file for the network interface:

# cat /etc/sysconfig/network-scripts/ifcfg-enp3s1 
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp3s1
UUID=5435015d-7174-414a-9fa3-9b5ec715a054
DEVICE=enp3s1
ONBOOT=yes

I had to change it to point to a bridge interface called bridge0.

# cat /etc/sysconfig/network-scripts/ifcfg-enp3s1 
DEVICE="enp3s1"
ONBOOT="yes"
NM_CONTROLLED="no"
#TYPE=Ethernet
BRIDGE=bridge0
BOOTPROTO=static

And this is where the new network configuration goes. It’s probably worth mentioning that it’s been changed from DHPC to a static IP address:

# cat /etc/sysconfig/network-scripts/ifcfg-bridge0
DEVICE="bridge0"
ONBOOT="yes"
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.0.103
NETMASK=255.255.255.0

and also that the GATEWAY has been moved to /etc/sysconfig/network.

# cat /etc/sysconfig/network
# Created by anaconda
GATEWAY=192.168.2.1

After

service network restart

you should be able to connect KVM VMs directly to the LAN.