Xen Cloud Platform (XCP) – Setting Up A VLAN

image_pdfimage_print

One very useful feature of XCP is the ability to setup VLAN networks for your virtual machines to use. This gives an administrator fine grained control on what network a machine belongs on. This will work as long as the network interface that is assigned to your VM’s is plugged into a trunked port on a switch that has been setup with VLAN tags.

In order to start assigning VLAN’s to a physical interface or pif in Xen terms do the following:

Get a list of the physical network interfaces and their corresponding UUID’s:

xe pif-list

This should return something similar to this:

uuid ( RO): 3ebae448-8520-1d92-32b8-322be6018909
device ( RO): eth0
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): 0eb1efb3-60c4-f754-ccee-607ea7419524

uuid ( RO): e602777f-b4e9-e231-7858-81189c47c434
device ( RO): eth1
currently-attached ( RO): true
VLAN ( RO): -1
network-uuid ( RO): df87728a-e4a7-a16e-9f8c-c4c4c26dc35f

This shows us the 2 network interfaces that are installed in the server. ETH0 is assigned as the management interface and ETH1 is assigned to the virtual machines.

Now we need to create a new network for our VLAN:

xe network-create name-label=network201

This creates a new network named network201 that corresponds to the VLAN tag 201 on the switch. When running this command you will get a uuid as output.

d14427c2-4940-0db1-7d96-f55434af319e

Now we need to assign the VLAN tag 201 to this network, and bind it to a physical interface (eth1 in this case):

xe vlan-create network-uuid=85a9aba5-73ea-4008-0a28-395c96be30fd \
pif-uuid=e602777f-b4e9-e231-7858-81189c47c434 vlan=201

Thats it the new VLAN201 is created and can be selected for use by your virtual machines. You can confirm it’s presence by doing:

xe pif-list

Which now will display your 2 physical interfaces as well as the new VLAN201 interface:

uuid ( RO): d14427c2-4940-0db1-7d96-f55434af319e
device ( RO): eth1
currently-attached ( RO): true
VLAN ( RO): 201
network-uuid ( RO): 85a9aba5-73ea-4008-0a28-395c96be30fd

8 Responses to “Xen Cloud Platform (XCP) – Setting Up A VLAN”


  1. Wu Shishan

    Hi,I have used XCP for days and I had install many VMs ,but the VM can not access the internet by DHCP ,how shoud I config the network.
    I’m looking forward to you respond.
    Thank you very much!

  2. Ronny

    Do the clients have access to a DHCP server on their VLAN? If not you will need to assign static addresses. The other thing to check is to make sure that they are receiving correct DNS server information via DHCP as well as a gateway IP address.

  3. sh

    Hi, thanks for the examples.
    However, in your example:
    “Now we need to assign the VLAN tag 201 to this network, and bind it to a physical interface (eth1 in this case):

    xe vlan-create network-uuid=85a9aba5-73ea-4008-0a28-395c96be30fd \
    pif-uuid=e602777f-b4e9-e231-7858-81189c47c434 vlan=201”

    where do you get 85a9aba5-73ea-4008-0a28-395c96be30fd from?

  4. Ronny

    That is what is returned after you use the xe network-create command.

  5. xen

    I’ve a question about this. I am a newbie on XEN and I am trying to add vlans to a bonded physical NIC. However it is not working as I expected. So I am checking open vswitch but I don’t know what’s the difference between xe command and open vswitch. should I use open vswitch?

  6. Ronny

    I have not dug into open vswitch enough to give you a good answer.

  7. Ted

    I had to fix one thing to make the plugin work:
    The line
    echo “Artist: ” . $artist[0];
    had to be
    echo “Artist: ” . $artist[2];
    in icestats_display.php
    and if you set a single space thusly
    echo $before_title;?> <?php echo $after_title;
    In the //Widget section of icestats.php you
    will suppress the generation of a title line.
    to pick up the artist name.
    People should note, this is not an ajax script. The information is presented as current when the page loads, and then is static thereafter.
    To make this easier to update, it would be better if the formatting lines that define
    $online
    $offline
    (New) $servernamelabel
    (New) $serverportlabel
    (new) $streammountlabel
    (New) $artistlabel
    (New) $songlabel
    (New) $clickhere
    (new) $tolisten
    (new) $plugintitle
    in a separate file for internationalization and reformatting. You could also set the URL of the file in the admin page, so you could have several language files, plus user files selected there.
    I reset formatting quite a bit in my implementation, and am concerned that an upgrade will overwrite that.

  8. Clay

    Anyone know how to use a bonded network as the base for the vlan network? (I need to move my managment node to a bonded/tagged interface. )

    We provision Trunked (or tagged) LACP for compute nodes, i.e. 4 bonded gige with vlan tags and 802.3ad bonding.

    Thanks,
    -Clay