如何给KVM上的VM配置VLAN?
- 2014.07.16
最近在给KVM上的VM配置vlan属性时,发现报文从KVM host发出去时, VLAN tag中的COS值被重置为0 (KVM 上的vm发出的报文为带VLAN tag,且cos值非0,但是报文被发出KVM host时,cos值被置为0。) 原因是因为KVM host 会将从vm收到的tag剥掉并重新打上vlan tag,数据流量虽通,但cos值却被修改为默认。
如何配置才能使KVM host保持vm本身发出报文的vlan 属性呢, 请参考如下配置
正确配置如下
# vconfigadd virbr2 2
# ifconfig virbr2.2 up
# brctladd if virbr2 eth0
# brctladd if virbr2 vnet1
# brctl show
bridge name bridge id STP enabled interfaces
virbr2 8000.001018d5c740 yes eth0
virbr2-nic
vnet1
ps:
eth0 is physical uplink port;
vnet1 is nic of vm, packets from vm carriy vlan id 2;
默认情况下,若不使用vlan, 直接将vnet1 和 eth0 绑到vbridge2即可;
具体细节可参考如下blog:
http://blog.davidvassallo.me/2012/05/05/kvm-brctl-in-linux-bringing-vlans-to-the-guests/
----------------------------------------------------------------------------
KVM& BRCTL IN LINUX – BRINGING VLANS TO THE GUESTS