Xen Virtual LAN

Describe XenDom0VLANstoDomUVirtualNICs here.

These are very simple instructions for mapping VLANs on the Dom0 through to the DomU NICs. Redhat/CentOS specific, and in this example the NICs were mapped through to a HVM Windoze box.

Other descriptions to help being picked up by search engines is: - VLAN trunk to virtual machine mapping - VLANs to DomU interfaces

Essentially: a. Create a bridge group for each .1q interface you want, and add the interfaces to the bridge. b. Map each virtual NIC to the bridge group. c. Don't forget to set the MTU in Windoze


1. Configure the bond interface, and create VLAN interfaces on the bond interface. Create a bridge and map each vlan interface into the bridge. All the files for this are at /etc/sysconfig/network-scripts/. (This examples creates VLAN 900-903.) You will need to change the HWADDR to match you NIC cards.

These are all the related files:

/etc/sysconfig/network-scripts/ifcfg-eth0

/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/ifcfg-bond0
/etc/sysconfig/network-scripts/ifcfg-bond0.900
/etc/sysconfig/network-scripts/ifcfg-bond0.901
/etc/sysconfig/network-scripts/ifcfg-bond0.902
/etc/sysconfig/network-scripts/ifcfg-bond0.903
/etc/sysconfig/network-scripts/ifcfg-br900
/etc/sysconfig/network-scripts/ifcfg-br901
/etc/sysconfig/network-scripts/ifcfg-br902
/etc/sysconfig/network-scripts/ifcfg-br903

1.1 These files configure the real ethernet ports to be part of an active/standby 'bond' interface.

/etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82541GI Gigabit Ethernet Controller

DEVICE=eth0
BOOTPROTO=none
HWADDR=00:15:17:28:f6:34
ONBOOT=yes
TYPE=Ethernet
#ETHTOOL_OPTS="autoneg off speed 100 duplex full"
MASTER=bond0
SLAVE=yes
USERCTL=no

/etc/sysconfig/network-scripts/ifcfg-eth1

# Intel Corporation 82566DM-2 Gigabit Network Connection

DEVICE=eth1
BOOTPROTO=none
HWADDR=00:15:17:28:f6:36
ONBOOT=yes
TYPE=Ethernet
#ETHTOOL_OPTS="autoneg off speed 100 duplex full"
MASTER=bond0
SLAVE=yes
USERCTL=no

1.2 This is the bond interface configuration.

Here the bond0 interface, in Dom0, is actually getting a IP via dhcp. You may want to set BOOTPROTO=none if you don't want this. The 'virtual mac' address is set here. Make sure this is unique.

/etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0

BOOTPROTO=dhcp
ONBOOT=yes
USERCTL=no
#PEERDNS=no
IPV6INIT=no
MACADDR=52:54:00:12:45:56
BONDING_OPTS="mode=1 miimon=100 primary=eth0"

1.3 Now create the bridges.

/etc/sysconfig/network-scripts/ifcfg-br900

DEVICE=br900

TYPE=Bridge
#STP=on
ONBOOT=yes
BOOTPROTO=none

...

DEVICE=br903

TYPE=Bridge
#STP=on
ONBOOT=yes
BOOTPROTO=none

1.4 Now the creation of all the VLAN interfaces, which are put into the bridges.

/etc/sysconfig/network-scripts/ifcfg-bond0.900

DEVICE=bond0.900

PHYSDEV=bond0
ONBOOT=yes
BOOTPROTO=none
VLAN=yes
BRIDGE=br900

...

DEVICE=bond0.903

PHYSDEV=bond0
ONBOOT=yes
BOOTPROTO=none
VLAN=yes
BRIDGE=br903

2. Load the bond-ing module.The main thing to add is below (rest of the bond is set in the file above). Reload or modprobe.

alias bond0 bonding

3. Finally, the important line in the Xen xm config file is:

vif = [ 'type=ioemu, bridge=br900', 'type=ioemu, bridge=br901',

'type=ioemu, bridge=br902', 'type=ioemu, bridge=br903' ]

4. Don't forget to set the MTU to 1494 using the 'regedit' if you are using windoze.


If you are using Centos/Redhat you can also use 'virsh' which has a XML virtual machine definition. 'virsh' seems to be strongly supported by Redhat, and XML is fairly clean, so instead of just using the 'xm' style files do this:



vm_name
256000
/usr/bin/pygrub
destroy
restart
restart
2