Open vSwitch的功能十分强大,我们的最终目的是在Open vSwitch之上构建kvm或者docker,并且隔离不必要的网络流量,下面我们看看vlan如何设置:

设置网桥br0,并且增加两个端口vlan10和vlan20,并给它们赋ip

ovs-vsctl add-br br0

ovs-vsctl add-port br0 vlan10 tag=10 -- set interface vlan10 type=internal  
ifconfig vlan10 192.168.10.254 netmask 255.255.255.0

ovs-vsctl add-port br0 vlan20 tag=20 -- set interface vlan20 type=internal  
ifconfig vlan20 192.168.20.254 netmask 255.255.255.0

ovs-vsctl show  

我们在Open vSwitch上构建生产2个kvm虚机

为kvm01内的eth0增加vlan tag,并设置ip:

vconfig add eth0 10  
ifconfig eth0.10 192.168.10.100 netmask 255.255.255.0 broadcast 192.168.10.255 up 

vconfig add eth0 20  
ifconfig eth0.20 192.168.20.100 netmask 255.255.255.0 broadcast 192.168.20.255 up  

为kvm02内的eth0增加vlan tag,并设置ip:

vconfig add eth0 10  
ifconfig eth0.10 192.168.10.101 netmask 255.255.255.0 broadcast 192.168.10.255 up 

vconfig add eth0 20  
ifconfig eth0.20 192.168.20.101 netmask 255.255.255.0 broadcast 192.168.20.255 up  

现在从kvm01里,分别ping kvm02里的地址192.168.10.101和192.168.20.101试试。

comments powered by Disqus