In this howto, we will explain how to setup VLANs and use them with XCP.

1/ Prerequired
1.1/ VLAN tagging capable switch

If you are using multiple physical hosts (with a master and multiple slaves),
they should be connected to a switch that understand VLAN tagging. You need to
ensure that your physical switch is in trunk mode, which means it will pass all
kinds of VLAN tagged network flow, and add corresponding VLAN tag to the ports
that connect to your server. This is the basic of a working VLAN.

1.2/ vconfig package

You need to have the vconfig package installed in your system (install it using
apt-get or dpkg -i).

1.3/ xcp-networkd mode: openvswitch

This howto also assumes that you are using XCP together with openvswitch, and
that the networking mode of XCP is using openvswitch: check that your
configuration in /etc/xcp/network.conf is set to "openvswitch" and not to
"bridge", if it's not the case change the value (by hand or using
"dpkg-reconfigure xcp-networkd" and reboot.

2/ Setting-up eth0 in the VLAN 100

Your /etc/network/interfaces configuration should look like this one:

auto lo
iface lo inet loopback

auto eth0.100
iface eth0.100 inet manual
        vlan_raw_device eth0

# The primary network interface
auto xenbr0
iface xenbr0 inet static
        bridge_ports eth0.100
        bridge_stp on
        address 192.168.0.123
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers 8.8.8.8
        dns-search example.com

This will make xenbr0 bridged to eth0.100, which means VLAN tag 100 on eth0.
As you can see, there's no definition of eth0. This is normal. There is no need
to write about iface eth0, neither bring those devices up explicitly, as the
network will be brought up in a dependency based manner.

In this very example, VLAN 100 was configured as the default tag on the
physical switch, which means everything no tagged will be tagged as 100. But
you are free to use other VLAN for the device as long as you have added the
VLANs to corresponding ports on your physical switch.

You can then continue with what we already have in README.Debian, to configure
the PIFs using "xe pif-reconfigure-ip" of your physical devices, namely eth0.

3/ Setting-up a VLAN for a bunch of virtual machines

...

4/ Creating a virtual machine and attaching it to the VLAN
