VLAN间路由可以通过二层交换机配合路由器来实现,也可以通过三层交换机来实现。
目录
注:
1. 路由器三层接口正常情况下不能正确识别带vlan tag的数据帧
2. 交换机所有子接口与主接口共享MAC地址
?
[S1]vlan batch 2 3
[S1]int g0/0/2
[S1-GigabitEthernet0/0/2]port link-type access
[S1-GigabitEthernet0/0/2]port default vlan 2
[S1-GigabitEthernet0/0/2]int g0/0/3
[S1-GigabitEthernet0/0/3]p l a
[S1-GigabitEthernet0/0/3]p d v 3
[S1-GigabitEthernet0/0/3]int g0/0/1
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[R1]int g0/0/0.2 //开启子接口并进入
[R1-GigabitEthernet0/0/0.2]ip add 192.168.2.254 24
[R1-GigabitEthernet0/0/0.2]dot1q termination vid 2 //剥离带有vlan2的标签
[R1-GigabitEthernet0/0/0.2]arp broadcast enable //开启arp广播
[R1-GigabitEthernet0/0/0.2]int g0/0/0.3
[R1-GigabitEthernet0/0/0.3]ip add 192.168.3.254 24
[R1-GigabitEthernet0/0/0.3]dot1q termination vid 3
[R1-GigabitEthernet0/0/0.3]arp broadcast enable
测试:vlan2与vlan3是否能通信?
成功!!
注:
dot1q termination vid ?????????(termination:终结,终结)
INTEGER<1-4094> ?Specify low VLAN ID命令有两个作用:
? ? ? ? ? ? ? ? 1.在收帧时剥离相应vlan tag
? ? ? ? ? ? ? ? 2.在发帧时打上相应vlan tag
[S1]vlan batch 2 3 100
[S1]int vlan 2
[S1-Vlanif2]ip add 192.168.2.254 24
[S1-Vlanif2]int vlan 100
[S1-Vlanif100]ip add 10.1.1.1 30
[S1-Vlanif100]int g0/0/1
[S1-GigabitEthernet0/0/1]p l a
[S1-GigabitEthernet0/0/1]p d v 2
[S1-GigabitEthernet0/0/1]int g0/0/2
[S1-GigabitEthernet0/0/2]p l t
[S1-GigabitEthernet0/0/2]p t a v 2 3 100
[S1-GigabitEthernet0/0/2]qu
[S1]ip route-static 0.0.0.0 0 10.1.1.2
[S2]vlan batch 2 3 100
[S2]int vlan 3
[S2-Vlanif3]ip add 192.168.3.254 24
[S2-Vlanif3]int vlan 100
[S2-Vlanif100]ip add 10.1.1.2 30
[S2-Vlanif100]int g0/0/01
[S2-GigabitEthernet0/0/1]p l a
[S2-GigabitEthernet0/0/1]p d v 3
[S2-GigabitEthernet0/0/1]int g0/0/2
[S2-GigabitEthernet0/0/2]p l t
[S2-GigabitEthernet0/0/2]p t a v 2 3 100
[S2-GigabitEthernet0/0/2]qu
[S2]ip route-static 0.0.0.0 0 10.1.1.1
测试:pc1能否和pc2ping通
成功!!