Today we are going to hop back into the KVM fray, and take a look at using CentOS as a hypervisor., and configuring very resilient network connections to support our guests. Of course these instructions should be valid on Red Hat Linux and Oracle Linux as well, though there is a little more to be done around getting access to the repos on those distributions…
Enable Bonding
I am assuming this is a first build for you, so this step might not be applicable, but it won’t hurt anything.
modprobe --first-time bondingConfigure the Physical Interfaces
In our example we will be using two physical interfaces, eth0 and eth1. Here are the interface configuration files.
cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=XX:XX:XX:XX:XX:XX
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=nocat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=XX:XX:XX:XX:XX:XX
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=noConfigure the Bonded Interface
Here we are going to bond the interfaces together, which will increase the resiliency of the interface.
cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="mode=1 miimon=100"
BRIDGE=br0Configure the Bridge
The final step is to configure the bridge itself, which is what KVM creates the vNIC on to allow for guest network communication.
cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DELAY=0Service Restart
Finally the easy part. Now one snag I ran into. If you created IP addresses on bond0, then you will have a tough time getting rid of that with a service restart alone. I found it was easier to reboot the box itself.
service network restart