逻辑图:
[需求]: 在KVM主机上有若干台虚拟机,它们分别属与不同的vlan,如上图的vlan10,vlan20,我们现在想实现vlan之间互通.
[实验步骤如下] 添加KVM主机vlan
more /etc/rc.local modprobe 8021q
vconfig add em2 10 vconfig add em2 20 ifconfig em2.10 up ifconfig em2.20 up brctl addbr br10 brctl addbr br20 ifconfig br10 up ifconfig br20 up brctl addif br10 em2.10 brctl addif br20 em2.20 启动虚拟机后将虚拟机生产的逻辑网口vnet0,vnet1分别加入到不同的vlan中. brctl addif br10 vnet0 brctl addif br20 vnet1
虚拟机配置不同的网段,如: Vm1:192.10.10.30 Vm2:192.20.20.30
此时: 需要配置交换机(3750) Kvm-vlan(config)#vlan database Kvm-vlan(vlan)#vlan 10 Kvm-vlan(vlan)#vlan 20 Kvm-vlan(vlan)#exit Kvm-vlan(config)#int vlan 10 Kvm-vlan(config-if)#ip address 192.10.10.1 255.255.255.0
Kvm-vlan(config)#int vlan 20 Kvm-vlan(config-if)#ip address 192.20.20.1 255.255.255.0
Kvm-vlan(config-if)#int fa 1/0/3 Kvm-vlan(config-if)#switchport trunkencapsulation dot1q Kvm-vlan(config-if)#switchport mode trunk Kvm-vlan(config-if)#no shut
Kvm-vlan(config)#ip routing
此时再在虚拟机之间互ping,可通!
技巧: 1.删除vlan ifconfig em2.10 down vconfig rem em2.10 2.将vlan配置添加到配置文件中
(责任编辑:IT) |