[CentOS-virt] Bonds, VLANs, and Bridges on Centos 5.6

Tue Nov 22 16:07:54 UTC 2011
Tait Clarridge <tait at taiter.com>

On Fri, 2011-11-18 at 17:56 -0500, Jason Nagashima wrote:
> Running on Centos 5.6 with KVM... 
> 
> I was wondering if anyone had any luck configuring the NICs where eth0 and eth1 are bonded together with vlan support to a bridge?
> 
> I noticed some threads show this as a possibility (http://lists.centos.org/pipermail/centos-virt/2009-November/001417.html), but haven't had any luck implementing it.  There also seems to be a bug with 5.6 (http://bugs.centos.org/view.php?id=4801), but that post died the day it was created it.
> 
> Any advice/working examples would be greatly appreciated.

Hi Jason,

I have had luck doing this with Xen, where I create bond0 on a trunk
interface and have xen bring it up as xenbr0 with pbond0 in the back
end.

You should be able to do roughly the same by creating a bridge interface
in /etc/sysconfig/network-scripts referencing bond0 as a member.

After that you should be able to run a script to create VLAN bridges
like the following:

#!/bin/bash
/sbin/modprobe 8021q

# Add your vlans here that you want with the numbers separated by a 
# space
VLANS="5 10 15 20"
# This should work with the bonding interface
TRUNKINT="bond0"
for VLAN in $VLANS
do
	vconfig add $TRUNKINT $VLAN
	brctl add br$VLAN
	brctl addif br$VLAN $TRUNKINT.$VLAN
	ifconfig $TRUNKINT.$VLAN up
	ifconfig br$VLAN up
done

I have done this with Xen on 5.5, 5.6 and 5.7... but it should work for
KVM. If you create the standard bridge interface br0 using just bond0
that will get you a trunk on whatever the native vlan is for that trunk.

Tait