The base Xen installation is configured such that all domains share a bridge to the first available ethernet interface. Although this makes testing VMs quick and painless, however our
VPS hosting plans needed to offer multiple ip address blocks to a single Dom0 with only 2 network cards so I started working with Vlans.
Now, you obviously need to have a Xen dom0 set up and running properly. Once you are at that point, adding VLAN bridging is fairly straightforward, CentOS 5.4 has vlaning already installed.
create ifcfg-eth0.2 (vlan2)
DEVICE=eth0.2
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
IPADDR=74.119.217.xxx
NETMASK=255.255.255.0
VLAN=yes
GATEWAY=74.119.217.x
create ifcfg-eth0.3 (vlan3)
DEVICE=eth0.3
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
VLAN=yes
ifconfig eth0
eth0 Link encap:Ethernet HWaddr A4:BA:DB:16:26:77
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:468338734 errors:0 dropped:0 overruns:0 frame:0
TX packets:498911873 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:156460216228 (145.7 GiB) TX bytes:114246923487 (106.4 GiB)
Interrupt:24 Memory:da000000-da012800
We only bring up the eth0 interface automatically but leave it unconfigured. It will not have an IP or any of the other usual information.
In this example the “vlan2″ interface is the replacement for your old “eth0″ interface. Its the interface you’ll be able to reach the dom0 on from the internal VLAN. The “vlan3″ interface is defined but is left unconfigured since there will be no publicly routeable path to the dom0.
Now we create a new network script for xen located at /etc/xen/scripts/network-bridge-wrapper
#!/bin/sh
/etc/xen/scripts/network-bridge netdev=eth0.2 start
/etc/xen/scripts/network-bridge netdev=eth0.3 start
That script basically just calls the standard “network-bridge” script supplied with Xen two times – once for each VLAN we are setting up.
Go ahead and add the call to that script in the place of network-bridge in /etc/xen/xend-config.sxp.
Now we need to do one final thing to another Xen script. By default, the xen-network-common.sh script calls “ifdown” directly to take an interface down. Unfortunately, this has the undesirable side effect of destroying any VLANs associated with that interface. This causes all kinds of problems when we call our “network-multi” script so we need to patch /etc/xen/scripts/xen-network-common.sh with the following section:
# do not call ifdown directly
ifdown() {
ip addr flush $1
ip link set $1 down
true
}
After youve done all that, reboot your dom0. You should now be up and running on the vlan interfaces. The output of “brctl show” should show this:
brctl show
bridge name bridge id STP enabled interfaces
eth0.100 8000.a4badb162677 no vifvm123.0
peth0.100
eth0.2 8000.a4badb162677 no vifvm138.0
vifvm137.0
vifvm127.0
vifvm126.0
vifvm125.0
peth0.2
eth0.3 8000.a4badb162677 no vifvm136.0
vifvm135.0
vifvm134.0
vifvm133.0
vifvm132.0
peth0.3
If so, you should be all ready to go. Now edit the vif line in your config file for a given domU to link its ethernet interface to a bridge.
vif = ['type=ioemu, ip=74.119.217.247 74.119.217.248, vifname=vifvm137.0, mac=00:16:3e:f3:28:f8, bridge=eth0.2']