VLANs with Open vs Switch Fake Bridges

4923 ワード

Original articale:http://blog.scottlowe.org/2012/10/19/vlans-with-open-vswitch-fake-bridges/
In other posts,I’ve talked about how to configure Open vs Switch(OVS)for use with VLANs.If you know the port to which a gust is connected,you can configure that particular port as a VLAN trunk lithke is:
ovs-vsctl set port <port name> trunks=10,11,12
This configration would pass the VLAN tags for VLANs 10,11,and 12 all the way up to the gust,where-asuming the OS installed in the gest has VLAN support—you could configure nective profigtwork
Alternally、if you know the port to which a particular gest is connected、You could configure that port as a VLAN access port with a command like this:
ovs-vsctl set port <port name> tag=15
This command makes the gusest a member of VLAN 15、much like the use of the switchport access vlan 15 command on a Cico switch.
The se command are all well and good、but there’s a couple problems here:
First,you must know which ports cores ponds to which gust domain.Thus far,I have been unable to determine what set of command help me(you)establish the mapping between portments/interfaces and determine the mashous。
Second,even if you do which ports cores ponds to which gust,the settings are ephemeraal.That is,when You power the Grest,the power-and its assited congration-goes away.You d the gthe fired
Claearly,this is not ideal.Fortunately,there is a worlound-a couble of them,actually.One worlound is toadd OVS and VLAN support to libvirt (something that is actually mentioned here).This is a great idea t-but it it doesn't work just.On some sysstems(I use Ubuntu 12.04.1 Lts with libvirt 0.1 0.2)the libvirt-VLAN integration causes an error.A pathas bemitteript.abred。
Without OVS/VLAN support in libvirt,we have only one other worlound:OVS fake bridges.OVS fake bridge.OVS fake brook and act like a bridge,but ar tied to a particular VLAN ID.I’m going to show you how to use OVS fake bridges to add VLAN supportto your OVS environment.
This post was written using Ubuntu 12.04.1 Lts with Open v Switch 1.4.0(straigout of the Precise Pangolin repositories).Please note that the command might swiightdifferent on on on on on on on the distritor.witters of the。
To create a fake bridge,you’ll use a modified form of the  ovs-vsctl add-br commmand.The command is so subtly different that I missed it quit a few times when reading through the documentation for  ovs-vsctl.Here’s the command you’ll need:
ovs-vsctl add-br <fake bridge> <parent bridge> <VLAN>
Let’s look at.example.Suppose you had an existing OVS bridge named ofrom,and you wanted to add a fake bridge to support VLAN 100.You would use use this command:
ovs-vsctl add-br vlan100 ovsbr0 100
When you create(or edit)a gust domain,you'll assign it to the new fake bridge(named)  vlan100 in this example.So,it might look something like this:
<interface type='bridge'>
  <mac address='11:22:33:aa:bb:cc'/>
  <source bridge='vlan100'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
Naturally、You could also create a libvirt virtual network that cores ponds to the fake bridge as well.(I'll likely post a separate around that idea.)
The n,when you powed up the gust domain and ran  ovs-vsctl show、you’d see something like this:
Bridge "ovsbr0"
    Port "bond0"
        Interface "eth1"
        Interface "eth2"
    Port "ovsbr0"
        Interface "ovsbr0"
            type: internal
    Port "vnet0"
        tag: 100
        Interface "vnet0"
    Port "vlan100"
        tag: 100
        Interface "vlan100"
            type: internal
Note that the gusest doman’s port/interface are atomatially given the fake bridge’s VLAN(,without any further interaction/configration required by the user or administra.Mch better!
Asuming you’re using fake bridges(and if you’re using OVS and VLANs、I’m not sure how You wouldn’t be)、there are a couple other couble monds You might find helpful as well:
The  ovs-vsctl br-to-vlan command Willprint the VLAN ID for a given bridge.If the bridge is a real bridge,the command returns 0;if the bridge is a fake bridge,it returns the VLAN ID.The  ovs-vsctl br-to-parent command returns the parent bridge for a given fake bridge.If the specified bridge is a real bridge,it returns the real bridge.Using fake bridges with link aggregation is also possible、as you can see from the snippet of OVS configration above.More information on on OVS with link aggregation is avlable here.