#Xen 4 dynamic VLANs through VIF-script

So last night i got really bored, so i tried to integrate VLANs in my existing Xen4 setup.

While googling for solutions, i only found things where i'd have to statically allocate VLANs for every customer on every host through xend-config.sxp network-script.

This also meant, that if i had a new customer vlan which i want to add to my host, i'd have to either restart xend or run

/etc/xen/scripts/network-bridge start netdev=eth1 vlan=5

Since this is absolutely not my style, i started investigating. Turns out there is a much better way to do so!

My current dom0 setup is as follows:
- ArchLinux minimal with gentoo-xen kernel patches (nothing special)
- eth0: mgmt link (domU migrations, ssh)
- eth1: data link (domU traffic/bridge)

First off, we disable the network-script directive in xend-config.sxp.
Second, we change vif-script directive to "vif-vlan-bridge".

Now place the following shellscript into /etc/xen/scripts/vif-vlan-bridge.

What does this do?

Well, now you can specify in your domU configuration file things like this:

vif = [ "mac=xyz,vlan=5,netdev=eth1" ]

This will create the desired vlan out of the given parameters whenever the domU starts up. It also checks if the vif is up, and therefor only tries to create it when it is not in "ip link sh".

It is working flawlessly so far, i'll monitor it over the next few days, but so far it looks very promising. So please have a crack at it! :)


Flattr me!

Tell your friends!