当网络中有多台交换机时,位于不同交换机上的相同VLAN
的主机之间时如何通信的呢?我们使用Trunk
实现跨交换机VLAN
通信。还有以太网通道
的操作哦。
实验拓扑
两台交换机直连,每台下面再连接两台VPC
,划分VLAN
,地址规划如下:
名称 | 接口 | VLAN | 地址 |
---|---|---|---|
PC1 | SW1-f1/0 | vlan 10 | 192.168.10.10/24 |
PC2 | SW1-f1/1 | vlan 20 | 192.168.10.20/24 |
PC3 | SW2-f1/0 | vlan 10 | 192.168.10.30/24 |
PC4 | SW2-f1/1 | vlan 20 | 192.168.10.40/24 |
配置方法
SW1(config)#interface fastEthernet 1/2SW1(config-if)#switchport mode trunkSW1(config-if)#switchport trunk encapsulation dot1qSW1(config-if)#end
配置过程
交换机划分 VLAN
- SW1
SW1#conf tSW1(config)#no ip routingSW1(config)#vlan 10,20SW1(config-vlan)#exSW1(config)#int f1/0SW1(config-if)#sw m aSW1(config-if)#sw a v 10SW1(config-if)#exSW1(config)#int f1/1SW1(config-if)#sw m aSW1(config-if)#sw a v 20SW1(config-if)#exSW1(config)#do show vlan-sw bVLAN Name Status Ports---- -------------------------------- --------- -------------------------------1 default active Fa1/2, Fa1/3, Fa1/4, Fa1/5 Fa1/6, Fa1/7, Fa1/8, Fa1/9 Fa1/10, Fa1/11, Fa1/12, Fa1/13 Fa1/14, Fa1/1510 VLAN0010 active Fa1/020 VLAN0020 active Fa1/11002 fddi-default act/unsup1003 token-ring-default act/unsup1004 fddinet-default act/unsup1005 trnet-default act/unsup
- SW2
SW2#conf tSW2(config)#no ip routingSW2(config)#vlan 10,20SW2(config-vlan)#exSW2(config)#int f1/0SW2(config-if)#sw m aSW2(config-if)#sw a v 10SW2(config-if)#exSW2(config)#int f1/1SW2(config-if)#sw m aSW2(config-if)#sw a v 20SW2(config-if)#exSW2(config)#do show vlan-sw bVLAN Name Status Ports---- -------------------------------- --------- -------------------------------1 default active Fa1/2, Fa1/3, Fa1/4, Fa1/5 Fa1/6, Fa1/7, Fa1/8, Fa1/9 Fa1/10, Fa1/11, Fa1/12, Fa1/13 Fa1/14, Fa1/1510 VLAN0010 active Fa1/020 VLAN0020 active Fa1/11002 fddi-default act/unsup1003 token-ring-default act/unsup1004 fddinet-default act/unsup1005 trnet-default act/unsup
配置 Trunk
- SW1
SW1(config)#interface fastEthernet 1/2SW1(config-if)#switchport mode trunkSW1(config-if)#switchport trunk encapsulation dot1qSW1(config-if)#end
- 查询验证
SW1#show interfaces fastEthernet 1/2 switchportName: Fa1/2Switchport: EnabledAdministrative Mode: trunkOperational Mode: trunkAdministrative Trunking Encapsulation: dot1qOperational Trunking Encapsulation: dot1qNegotiation of Trunking: DisabledAccess Mode VLAN: 0 ((Inactive))Trunking Native Mode VLAN: 1 (default)Trunking VLANs Enabled: ALLTrunking VLANs Active: 1,10,20Protected: falsePriority for untagged frames: 0Override vlan tag priority: FALSEVoice VLAN: noneAppliance trust: none
- SW2
SW2(config)#int f1/2SW2(config-if)#sw m tSW2(config-if)#sw t e dSW2(config-if)#do show int f1/2 switchportName: Fa1/2Switchport: EnabledAdministrative Mode: trunkOperational Mode: trunkAdministrative Trunking Encapsulation: dot1qOperational Trunking Encapsulation: dot1qNegotiation of Trunking: DisabledAccess Mode VLAN: 0 ((Inactive))Trunking Native Mode VLAN: 1 (default)Trunking VLANs Enabled: ALLTrunking VLANs Active: 1,10,20Protected: falsePriority for untagged frames: 0Override vlan tag priority: FALSEVoice VLAN: noneAppliance trust: none
PING 测试
- PC1
PC1> ip 192.168.10.10Checking for duplicate address...PC1 : 192.168.10.10 255.255.255.0PC1> ping 192.168.10.20host (192.168.10.20) not reachablePC1> ping 192.168.10.3084 bytes from 192.168.10.30 icmp_seq=1 ttl=64 time=1.876 ms84 bytes from 192.168.10.30 icmp_seq=2 ttl=64 time=1.853 ms84 bytes from 192.168.10.30 icmp_seq=3 ttl=64 time=1.992 ms84 bytes from 192.168.10.30 icmp_seq=4 ttl=64 time=0.000 ms84 bytes from 192.168.10.30 icmp_seq=5 ttl=64 time=1.853 msPC1> ping 192.168.10.40host (192.168.10.40) not reachable
PC1 PING PC3 抓包
- 在
SW1
的F1/0
接口开启抓包
- 在
SW1
的F1/2
接口开启抓包
数据包在出交换机时被打上
vlan 10
的标签。
- PC2
PC2> ip 192.168.10.20Checking for duplicate address...PC1 : 192.168.10.20 255.255.255.0PC2> ping 192.168.10.10host (192.168.10.10) not reachablePC2> ping 192.168.10.30host (192.168.10.30) not reachablePC2> ping 192.168.10.4084 bytes from 192.168.10.40 icmp_seq=1 ttl=64 time=1.992 ms84 bytes from 192.168.10.40 icmp_seq=2 ttl=64 time=1.999 ms84 bytes from 192.168.10.40 icmp_seq=3 ttl=64 time=1.870 ms84 bytes from 192.168.10.40 icmp_seq=4 ttl=64 time=1.842 ms84 bytes from 192.168.10.40 icmp_seq=5 ttl=64 time=1.846 ms
PC2 PING PC4 抓包
- 在
SW1
的F1/1
接口开启抓包
- 在
SW1
的F1/2
接口开启抓包
数据包在出交换机时被打上
vlan 20
的标签。
- PC3
PC3> ip 192.168.10.30Checking for duplicate address...PC1 : 192.168.10.30 255.255.255.0PC3> ping 192.168.10.1084 bytes from 192.168.10.10 icmp_seq=1 ttl=64 time=1.878 ms84 bytes from 192.168.10.10 icmp_seq=2 ttl=64 time=1.849 ms84 bytes from 192.168.10.10 icmp_seq=3 ttl=64 time=1.840 ms84 bytes from 192.168.10.10 icmp_seq=4 ttl=64 time=1.842 ms84 bytes from 192.168.10.10 icmp_seq=5 ttl=64 time=1.845 msPC3> ping 192.168.10.20host (192.168.10.20) not reachablePC3> ping 192.168.10.40host (192.168.10.40) not reachable
- PC4
PC4> ip 192.168.10.40Checking for duplicate address...PC1 : 192.168.10.40 255.255.255.0PC4> ping 192.168.10.10host (192.168.10.10) not reachablePC4> ping 192.168.10.2084 bytes from 192.168.10.20 icmp_seq=1 ttl=64 time=1.962 ms84 bytes from 192.168.10.20 icmp_seq=2 ttl=64 time=1.994 ms84 bytes from 192.168.10.20 icmp_seq=3 ttl=64 time=1.981 ms84 bytes from 192.168.10.20 icmp_seq=4 ttl=64 time=1.991 ms84 bytes from 192.168.10.20 icmp_seq=5 ttl=64 time=1.965 msPC4> ping 192.168.10.30host (192.168.10.30) not reachable
以太网通道
创建以太网通道可以增加链路的带宽,以及可靠性。
拓扑图
在当前实验的基础上,在交换机之间增加一条链路。
配置过程
接口配成 Trunk
- SW1
SW1#conf tSW1(config)#int f1/3SW1(config-if)#sw m tSW1(config-if)#sw t e dSW1(config-if)#no sh
- SW2
SW2#conf tSW2(config)#int f1/3SW2(config-if)#sw m tSW2(config-if)#sw t e dSW2(config-if)#no sh
接口绑定到一起
- SW1
SW1(config-if)#exitSW1(config)#int range fastEthernet 1/2 - 3SW1(config-if-range)#channel-group 1 mode onCreating a port-channel interface Port-channel1SW1(config-if-range)#*Mar 1 00:56:50.555: %EC-5-BUNDLE: Interface Fa1/2 joined port-channel Po1SW1(config-if-range)#*Mar 1 00:56:53.487: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up
- SW2
SW2(config-if)#exSW2(config)#int r f1/2 - 3SW2(config-if-range)#ch 1 m oCreating a port-channel interface Port-channel1SW2(config-if-range)#*Mar 1 01:00:16.955: %EC-5-BUNDLE: Interface Fa1/2 joined port-channel Po1SW2(config-if-range)#*Mar 1 01:00:19.875: %LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up
故障模拟
验证以太网通道的可靠性,断开两个交换机的
f1/2
接口,查看连通性。事先使用PC1
对PC3
进行长PING
。
- 断开接口
SW1(config-if-range)#exSW1(config)#int f1/2SW1(config-if)#shSW1(config-if)#*Mar 1 01:05:35.947: %EC-5-UNBUNDLE: Interface Fa1/2 left the port-channel Po1*Mar 1 01:05:35.995: %EC-5-BUNDLE: Interface Fa1/3 joined port-channel Po1*Mar 1 01:05:36.451: %DTP-5-NONTRUNKPORTON: Port Fa1/2 has become non-trunk*Mar 1 01:05:36.491: %DTP-5-TRUNKPORTON: Port Fa1/3 has become dot1q trunkSW1(config-if)#*Mar 1 01:05:37.887: %LINK-5-CHANGED: Interface FastEthernet1/2, changed state to administratively downSW1(config-if)#*Mar 1 01:05:37.947: %LINK-3-UPDOWN: Interface Port-channel1, changed state to upSW1(config-if)#*Mar 1 01:05:38.887: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/2, changed state to down*Mar 1 01:05:38.991: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/3, changed state to up
SW2(config-if-range)#exSW2(config)#int f1/2SW2(config-if)#shSW2(config-if)#*Mar 1 01:06:57.415: %EC-5-UNBUNDLE: Interface Fa1/2 left the port-channel Po1*Mar 1 01:06:57.447: %EC-5-BUNDLE: Interface Fa1/3 joined port-channel Po1*Mar 1 01:06:57.915: %DTP-5-NONTRUNKPORTON: Port Fa1/2 has become non-trunk*Mar 1 01:06:57.947: %DTP-5-TRUNKPORTON: Port Fa1/3 has become dot1q trunkSW2(config-if)#*Mar 1 01:06:59.375: %LINK-5-CHANGED: Interface FastEthernet1/2, changed state to administratively downSW2(config-if)#*Mar 1 01:06:59.411: %LINK-3-UPDOWN: Interface Port-channel1, changed state to upSW2(config-if)#*Mar 1 01:07:00.375: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/2, changed state to down*Mar 1 01:07:00.443: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/3, changed state to up
- PING 测试
PC1> ping 192.168.10.30 -t84 bytes from 192.168.10.30 icmp_seq=1 ttl=64 time=1.975 ms84 bytes from 192.168.10.30 icmp_seq=2 ttl=64 time=1.866 ms84 bytes from 192.168.10.30 icmp_seq=3 ttl=64 time=1.849 ms84 bytes from 192.168.10.30 icmp_seq=4 ttl=64 time=0.978 ms84 bytes from 192.168.10.30 icmp_seq=5 ttl=64 time=1.851 ms84 bytes from 192.168.10.30 icmp_seq=6 ttl=64 time=1.842 ms84 bytes from 192.168.10.30 icmp_seq=7 ttl=64 time=1.896 ms84 bytes from 192.168.10.30 icmp_seq=8 ttl=64 time=1.879 ms84 bytes from 192.168.10.30 icmp_seq=9 ttl=64 time=1.877 ms84 bytes from 192.168.10.30 icmp_seq=10 ttl=64 time=1.853 ms84 bytes from 192.168.10.30 icmp_seq=11 ttl=64 time=1.988 ms84 bytes from 192.168.10.30 icmp_seq=12 ttl=64 time=1.846 ms84 bytes from 192.168.10.30 icmp_seq=13 ttl=64 time=1.839 ms84 bytes from 192.168.10.30 icmp_seq=14 ttl=64 time=1.996 ms84 bytes from 192.168.10.30 icmp_seq=15 ttl=64 time=1.847 ms84 bytes from 192.168.10.30 icmp_seq=16 ttl=64 time=1.862 ms84 bytes from 192.168.10.30 icmp_seq=17 ttl=64 time=1.847 ms84 bytes from 192.168.10.30 icmp_seq=18 ttl=64 time=1.886 ms84 bytes from 192.168.10.30 icmp_seq=19 ttl=64 time=1.849 ms84 bytes from 192.168.10.30 icmp_seq=20 ttl=64 time=1.844 ms84 bytes from 192.168.10.30 icmp_seq=21 ttl=64 time=1.886 ms84 bytes from 192.168.10.30 icmp_seq=22 ttl=64 time=1.844 ms84 bytes from 192.168.10.30 icmp_seq=23 ttl=64 time=1.889 ms84 bytes from 192.168.10.30 icmp_seq=24 ttl=64 time=1.858 ms84 bytes from 192.168.10.30 icmp_seq=25 ttl=64 time=1.965 ms84 bytes from 192.168.10.30 icmp_seq=26 ttl=64 time=1.842 ms84 bytes from 192.168.10.30 icmp_seq=27 ttl=64 time=1.848 ms84 bytes from 192.168.10.30 icmp_seq=28 ttl=64 time=1.997 ms84 bytes from 192.168.10.30 icmp_seq=29 ttl=64 time=1.843 ms84 bytes from 192.168.10.30 icmp_seq=30 ttl=64 time=1.972 ms84 bytes from 192.168.10.30 icmp_seq=31 ttl=64 time=1.847 ms84 bytes from 192.168.10.30 icmp_seq=32 ttl=64 time=1.844 ms84 bytes from 192.168.10.30 icmp_seq=33 ttl=64 time=0.968 ms192.168.10.30 icmp_seq=34 timeout192.168.10.30 icmp_seq=35 timeout192.168.10.30 icmp_seq=36 timeout192.168.10.30 icmp_seq=37 timeout192.168.10.30 icmp_seq=38 timeout192.168.10.30 icmp_seq=39 timeout192.168.10.30 icmp_seq=40 timeout192.168.10.30 icmp_seq=41 timeout192.168.10.30 icmp_seq=42 timeout192.168.10.30 icmp_seq=43 timeout192.168.10.30 icmp_seq=44 timeout192.168.10.30 icmp_seq=45 timeout192.168.10.30 icmp_seq=46 timeout192.168.10.30 icmp_seq=47 timeout192.168.10.30 icmp_seq=48 timeout192.168.10.30 icmp_seq=49 timeout192.168.10.30 icmp_seq=50 timeout192.168.10.30 icmp_seq=51 timeout192.168.10.30 icmp_seq=52 timeout192.168.10.30 icmp_seq=53 timeout192.168.10.30 icmp_seq=54 timeout192.168.10.30 icmp_seq=55 timeout192.168.10.30 icmp_seq=56 timeout192.168.10.30 icmp_seq=57 timeout192.168.10.30 icmp_seq=58 timeout192.168.10.30 icmp_seq=59 timeout192.168.10.30 icmp_seq=60 timeout192.168.10.30 icmp_seq=61 timeout192.168.10.30 icmp_seq=62 timeout192.168.10.30 icmp_seq=63 timeout192.168.10.30 icmp_seq=64 timeout192.168.10.30 icmp_seq=65 timeout192.168.10.30 icmp_seq=66 timeout192.168.10.30 icmp_seq=67 timeout192.168.10.30 icmp_seq=68 timeout192.168.10.30 icmp_seq=69 timeout192.168.10.30 icmp_seq=70 timeout192.168.10.30 icmp_seq=71 timeout192.168.10.30 icmp_seq=72 timeout192.168.10.30 icmp_seq=73 timeout192.168.10.30 icmp_seq=74 timeout192.168.10.30 icmp_seq=75 timeout192.168.10.30 icmp_seq=76 timeout192.168.10.30 icmp_seq=77 timeout192.168.10.30 icmp_seq=78 timeout192.168.10.30 icmp_seq=79 timeout192.168.10.30 icmp_seq=80 timeout192.168.10.30 icmp_seq=81 timeout192.168.10.30 icmp_seq=82 timeout192.168.10.30 icmp_seq=83 timeout192.168.10.30 icmp_seq=84 timeout192.168.10.30 icmp_seq=85 timeout192.168.10.30 icmp_seq=86 timeout192.168.10.30 icmp_seq=87 timeout192.168.10.30 icmp_seq=88 timeout192.168.10.30 icmp_seq=89 timeout84 bytes from 192.168.10.30 icmp_seq=90 ttl=64 time=1.846 ms84 bytes from 192.168.10.30 icmp_seq=91 ttl=64 time=1.982 ms84 bytes from 192.168.10.30 icmp_seq=92 ttl=64 time=1.840 ms84 bytes from 192.168.10.30 icmp_seq=93 ttl=64 time=1.849 ms84 bytes from 192.168.10.30 icmp_seq=94 ttl=64 time=1.841 ms84 bytes from 192.168.10.30 icmp_seq=95 ttl=64 time=1.846 ms84 bytes from 192.168.10.30 icmp_seq=96 ttl=64 time=1.841 ms84 bytes from 192.168.10.30 icmp_seq=97 ttl=64 time=1.861 ms84 bytes from 192.168.10.30 icmp_seq=98 ttl=64 time=0.844 ms84 bytes from 192.168.10.30 icmp_seq=99 ttl=64 time=0.833 ms
最后
这是关于使用Trunk
实现跨交换机VLAN
通信的实验,和以太网通道怎么创建方法。下一篇关于三层交换的实验。