场景:
在工作上遇到了相关的问题,所以在这整理一下相同的vlan是如何跨交换机通信的。
拓扑图
要求
PC1与PC4可以通信,与PC2/PC3之间无法通信。
PC2与PC5可以通信,与PC1/PC3之间无法通信。
PC3与PC6可以通信,与PC1/PC2之间无法通信。
配置
第一台交换机(LSW3)配置
<Huawei>undo terminal monitor
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SWA
[SWA]user-interface console 0
[SWA-ui-console0]idle-timeout 0 0
[SWA-ui-console0]quit
[SWA]vlan bat 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWA]int e0/0/1
[SWA-Ethernet0/0/1]port link-type trunk
[SWA-Ethernet0/0/1]port link-type access
[SWA-Ethernet0/0/1]port default vlan 10
[SWA-Ethernet0/0/1]q
[SWA]int e0/0/22
[SWA-Ethernet0/0/22]port link-type trunk
[SWA-Ethernet0/0/22]port trunk allow-pass vlan 10 20 30
[SWA-Ethernet0/0/22]q
[SWA]int e0/0/2
[SWA-Ethernet0/0/2]port link-type access
[SWA-Ethernet0/0/2]port default vlan 20
[SWA-Ethernet0/0/2]q
[SWA]int e0/0/3
[SWA-Ethernet0/0/3]port link-type access
[SWA-Ethernet0/0/3]port default vlan 30
[SWA-Ethernet0/0/3]q
第二台交换机(LSW4)配置
<Huawei>
<Huawei>undo terminal monitor
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SWB
[SWB]user-interface console 0
[SWB-ui-console0]idle-timeout 0 0
[SWB-ui-console0]quit
[SWB]vlan bat 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWB]int e0/0/1
[SWB-Ethernet0/0/1]port link-type access
[SWB-Ethernet0/0/1]port default vlan 10
[SWB-Ethernet0/0/1]q
[SWB]int e0/0/22
[SWB-Ethernet0/0/22]port link-type trunk
[SWB-Ethernet0/0/22]port trunk allow-pass vlan 10 20 30
[SWB-Ethernet0/0/22]q
[SWB]int e0/0/2
[SWB-Ethernet0/0/2]port link-type access
[SWB-Ethernet0/0/2]port default vlan 20
[SWB-Ethernet0/0/2]q
[SWB]int e0/0/3
[SWB-Ethernet0/0/3]port link-type access
[SWB-Ethernet0/0/3]port default vlan 30
[SWB-Ethernet0/0/3]q
测试联通性
PC1与PC4能通
PC1与PC2不通
PC4与PC5/PC6不通
测试结果说明配置成功
总结
交换机给往其他交换机的数据帧打上VLAN标识,经过中继链路传输,带VLAN标签的数据到达接收方后,接收方交换机会去除掉VLAN标签,根据MAC地址表,实现VLAN标签对应的端口的数据转发。