[CentOS-virt] VLAN bridge config for xen - Was: Controlling allocation of ethernet devices and KVM

Fri Nov 27 17:33:10 UTC 2009
Tait Clarridge <tait at clarridge.ca>

On Fri, 2009-11-27 at 12:12 -0500, Kelvin Edmison wrote:
> On 26/11/09 10:16 PM, "Tait Clarridge" <tait at clarridge.ca> wrote:
> > On Fri, 2009-11-27 at 14:02 +1300, Steven Ellis wrote:
> > 
> > So if I have this right, at the basic level you wish to have:
> > 
> > - One interface for Host machine
> > - Multiple interfaces for guest traffic
> > 
> > If your environment supports VLANs (802.1Q), might I suggest a trunk
> > port on eth1 split up into different bridges to have the KVM guests go
> > through to get on different VLANs/address spaces.
> > 
> > This is what I currently do for Xen and it works great. What kind of
> > network setup to you have?
> Could you please provide some pointers on how you accomplished this?  I've
> been attempting to set up a similar configuration without success.
> Thanks, 
>   Kelvin


The way we would do it for a 2 NIC box would be:

eth0 - VLAN trunk
eth1 - Storage Network VLAN

After you have been given a trunk port with a native vlan (for eth0,
allowing you to set an IP for this connection) you can run or script the

- Load the VLAN module

modprobe 8021q

- Use vconfig to add VLAN interfaces
- This is going to assume that eth0 is your trunk port
- eg. vconfig add eth0 <vlan number>
- So for VLAN 22 it would be:

vconfig add eth0 22

- Add the bridge for xen to use (requires bridge-utils package)
- eg. brctl addbr xenbr<vlan#>
- VLAN 22 would be:

brctl addbr xenbr22

- Add the VLAN interface to the bridge
- eg. brctl addif xenbr<vlan#> eth0.<vlan#>
- VLAN 22 would be:

brctl addif xenbr22 eth0.22

- Bring both the bridge and the VLAN interface up
- eg. ifconfig eth0.<vlan#> up
- eg. ifconfig xenbr<vlan#> up
- VLAN 22 would be:

ifconfig eth0.22 up
ifconfig xenbr22 up

If you wanted to script it to run at boot time you can create a simple
for loop with a list of VLANs to use.

In this case I want to use VLANS:
- 2
- 4
- 6
- 8
- 200
- 120

The script would start as follows:


VLANS="2 4 6 8 200 120"
modprobe 8021q

for i in $VLANS
		# above commands go here 
		# starting from vconfig add eth0 22

		# just change 22 from the examples to $i

If you have any trouble, let me know.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.centos.org/pipermail/centos-virt/attachments/20091127/5582f897/attachment-0002.sig>