1.广播风暴
以下图为例
配置交换机LSW1
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW1 [LSW1]stp Sep 14 2023 05:35:15-08:00 LSW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095. ^ Error:Incomplete command found at '^' position. [LSW1]undo info-center enable Info: Information center is disabled. [LSW1]stp mode stp Info: This operation may take a few seconds. Please wait for a moment...done. [LSW1]display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-cc15-19c9 Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-19c9 / 0 CIST RegRoot/IRPC :32768.4c1f-cc15-19c9 / 0 CIST RootPortId :0.0 BPDU-Protection :Disabled TC or TCN received :2 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:1m:27s Number of TC :4 Last TC occurred :GigabitEthernet0/0/3 ----[Port1(GigabitEthernet0/0/1)][LEARNING]---- Port Protocol :Enabled Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc15-19c9 / 128.1 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 packets/hello-time Protection Type :None [LSW1]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW1]display mac-address 端口 STP角色 STP状态 端口ID GE 0/0/1 指定端口 FORWARDING (转发) 0 GE 0/0/2 指定端口 FORWARDING (转发) 0 GE 0/0/3 指定端口 FORWARDING (转发) 0
禁用g0/0/1和g0/0/2端口
[LSW1]display mac-address [LSW1]interface gigabitethernet 0/0/1 [LSW1-GigabitEthernet0/0/1]undo stp enable [LSW1-GigabitEthernet0/0/1]qu [LSW1]interface gigabitethernet 0/0/2 [LSW1-GigabitEthernet0/0/2]undo stp enable [LSW1-GigabitEthernet0/0/2]qu
对LSW2做同样的操作
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW2 [LSW2]stp mode stp Info: This operation may take a few seconds. Please wait for a moment...done. [LSW2] Sep 14 2023 05:44:17-08:00 LSW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095. [LSW2]undo info-center enable Info: Information center is disabled. [LSW2]display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-cc39-46ec Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc39-46ec / 0 CIST RegRoot/IRPC :32768.4c1f-cc39-46ec / 0 CIST RootPortId :0.0 BPDU-Protection :Disabled TC or TCN received :108 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:3m:14s Number of TC :10 Last TC occurred :GigabitEthernet0/0/2 ----[Port1(GigabitEthernet0/0/1)][LEARNING]---- Port Protocol :Enabled Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc39-46ec / 128.1 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 packets/hello-time Protection Type :None [LSW2]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW2]display mac-address [LSW2]interface g0/0/1 [LSW2-GigabitEthernet0/0/1]undo stp enable [LSW2-GigabitEthernet0/0/1]qu [LSW2]interface g0/0/2 [LSW2-GigabitEthernet0/0/2]undo stp enable [LSW2-GigabitEthernet0/0/2]qu
当我们互ping两个PC时,即
PC>ping 192.168.100.19 -c 8
PC>ping 192.168.100.29 -c 8
#会出现请求超时的现象
Ping 192.168.100.19: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
这时我们再查看mac地址表
[LSW1]display mac-address MAC address table of slot 0: ------------------------------------------------------------------------------- MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID VSI/SI MAC-Tunnel ------------------------------------------------------------------------------- 5489-9880-36b4 1 - - GE0/0/1 dynamic 0/- 5489-98a8-0ea0 1 - - GE0/0/2 dynamic 0/- ------------------------------------------------------------------------------- Total matching items on slot 0 displayed = 2 [LSW2]display mac-address MAC address table of slot 0: ------------------------------------------------------------------------------- MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID VSI/SI MAC-Tunnel ------------------------------------------------------------------------------- 5489-9880-36b4 1 - - GE0/0/2 dynamic 0/- 5489-98a8-0ea0 1 - - GE0/0/1 dynamic 0/- ------------------------------------------------------------------------------- Total matching items on slot 0 displayed = 2
这时可以看到数据抓包,数据抓取速度很快,出现广播风暴,瞬间几千条数据,在交换机中输入命令时也会出现明显延迟
在不同的时间段查看LSW2的mac地址表
可以看到同一mac地址,记录了不同的端口(mac地址震荡)
这是由于广播风暴导致广播消息在网络中被无限循环转发,交换机会不断地接收到重复的广播消息,并会记录下每个消息的源MAC地址和接收端口。这时cpu的利用率也会不断提高,网络性能变差。
[LSW2]display mac-address MAC address table of slot 0: ------------------------------------------------------------------------------- MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID VSI/SI MAC-Tunnel ------------------------------------------------------------------------------- 5489-9880-36b4 1 - - GE0/0/1 dynamic 0/- 5489-98a8-0ea0 1 - - GE0/0/2 dynamic 0/- ------------------------------------------------------------------------------- Total matching items on slot 0 displayed = 2 [LSW2]display mac-address MAC address table of slot 0: ------------------------------------------------------------------------------- MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID VSI/SI MAC-Tunnel ------------------------------------------------------------------------------- 5489-9880-36b4 1 - - GE0/0/2 dynamic 0/- 5489-98a8-0ea0 1 - - GE0/0/1 dynamic 0/- ------------------------------------------------------------------------------- Total matching items on slot 0 displayed = 2
2.解决方法:配置STP
以下图为例
配置LSW1
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW1 [LSW1] Sep 14 2023 06:29:37-08:00 LSW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095. [LSW1]UNDO info-center enable Info: Information center is disabled. [LSW1]stp mode stp Info: This operation may take a few seconds. Please wait for a moment...done. [LSW1]display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-cc15-4618 Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-4618 / 0 CIST RegRoot/IRPC :32768.4c1f-cc15-4618 / 0 CIST RootPortId :0.0 BPDU-Protection :Disabled TC or TCN received :5 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:2m:14s Number of TC :5 Last TC occurred :GigabitEthernet0/0/1 ----[Port1(GigabitEthernet0/0/1)][DISCARDING]---- Port Protocol :Enabled Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc15-4618 / 128.1 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 packets/hello-time Protection Type :None [LSW1]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI LEARNING NONE 0 GigabitEthernet0/0/2 DESI LEARNING NONE 0 GigabitEthernet0/0/3 DESI LEARNING NONE [LSW1]display stp interface g0/0/1 -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-cc15-4618 Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-4618 / 0 CIST RegRoot/IRPC :32768.4c1f-cc15-4618 / 0 CIST RootPortId :0.0 BPDU-Protection :Disabled TC or TCN received :5 TC count per hello :0 STP Converge Mode :Normal Time since last TC :0 days 0h:0m:29s Number of TC :8 Last TC occurred :GigabitEthernet0/0/3 ----[Port1(GigabitEthernet0/0/1)][FORWARDING]---- Port Protocol :Enabled Port Role :Designated Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc15-4618 / 128.1 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 pack [LSW1]display stp interface g0/0/1 brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE [LSW1]display mac-address
对交换机LSW2采用同样的配置
具有最高优先级的交换机被选为根网桥。若优先级相等,则具有最小MAC 地址的交换机被选为根网桥。默认情况下,交换机的优先级是 32768,在这里将LSW2的优先级设置为8192
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW2 [LSW2]STP Sep 14 2023 06:33:29-08:00 LSW2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095. ^ Error:Incomplete command found at '^' position. [LSW2]undo info-center enable Info: Information center is disabled. [LSW2]stp mode stp Info: This operation may take a few seconds. Please wait for a moment...done. [LSW2]display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-ccd4-5efe Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-4618 / 40000 CIST RegRoot/IRPC :32768.4c1f-ccd4-5efe / 0 CIST RootPortId :128.1 BPDU-Protection :Disabled TC or TCN received :62 TC count per hello :2 STP Converge Mode :Normal Time since last TC :0 days 0h:3m:24s Number of TC :6 Last TC occurred :GigabitEthernet0/0/1 ----[Port1(GigabitEthernet0/0/1)][DISCARDING]---- Port Protocol :Enabled Port Role :Root Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc75-09aa / 128.3 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 packets/hello-time Protection Type :None [LSW2]display stp int g0/0/1 -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-ccd4-5efe Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-4618 / 40000 CIST RegRoot/IRPC :32768.4c1f-ccd4-5efe / 0 CIST RootPortId :128.1 BPDU-Protection :Disabled TC or TCN received :78 TC count per hello :2 STP Converge Mode :Normal Time since last TC :0 days 0h:3m:42s Number of TC :6 Last TC occurred :GigabitEthernet0/0/1 ----[Port1(GigabitEthernet0/0/1)][LEARNING]---- Port Protocol :Enabled Port Role :Root Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc75-09aa / 128.3 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 packets/hello-time Protection Type :None [LSW2]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE 0 GigabitEthernet0/0/2 ALTE DISCARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW2]display stp int g0/0/1 brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE [LSW2]display mac-address #设置优先级 [LSW2]stp priority 8192 [LSW2]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI DISCARDING NONE 0 GigabitEthernet0/0/2 DESI DISCARDING NONE 0 GigabitEthernet0/0/3 DESI DISCARDING NONE [LSW2]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW2]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW2]display stp int g 0/0/1 brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 对交换机LSW3采用同样的配置 <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW3 [LSW3] Sep 14 2023 06:36:08-08:00 LSW3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.2 5.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095. [LSW3]undo info-center enable Info: Information center is disabled. [LSW3]stp mode stp Info: This operation may take a few seconds. Please wait for a moment...done. [LSW3]display stp -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-cc75-09aa Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-4618 / 20000 CIST RegRoot/IRPC :32768.4c1f-cc75-09aa / 0 CIST RootPortId :128.1 BPDU-Protection :Disabled TC or TCN received :93 TC count per hello :2 STP Converge Mode :Normal Time since last TC :0 days 0h:2m:13s Number of TC :13 Last TC occurred :GigabitEthernet0/0/3 ----[Port1(GigabitEthernet0/0/1)][DISCARDING]---- Port Protocol :Enabled Port Role :Root Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc15-4618 / 128.1 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 packets/hello-time Protection Type :None [LSW3]display stp int g0/0/1 -------[CIST Global Info][Mode STP]------- CIST Bridge :32768.4c1f-cc75-09aa Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20 CIST Root/ERPC :32768.4c1f-cc15-4618 / 20000 CIST RegRoot/IRPC :32768.4c1f-cc75-09aa / 0 CIST RootPortId :128.1 BPDU-Protection :Disabled TC or TCN received :104 TC count per hello :1 STP Converge Mode :Normal Time since last TC :0 days 0h:2m:26s Number of TC :13 Last TC occurred :GigabitEthernet0/0/3 ----[Port1(GigabitEthernet0/0/1)][LEARNING]---- Port Protocol :Enabled Port Role :Root Port Port Priority :128 Port Cost(Dot1T ) :Config=auto / Active=20000 Designated Bridge/Port :32768.4c1f-cc15-4618 / 128.1 Port Edged :Config=default / Active=disabled Point-to-point :Config=auto / Active=true Transit Limit :147 pack [LSW3]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ROOT LEARNING NONE 0 GigabitEthernet0/0/2 ALTE DISCARDING NONE 0 GigabitEthernet0/0/3 DESI LEARNING NONE 0 GigabitEthernet0/0/4 DESI LEARNING NONE [LSW3]display stp int g0/0/1 brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE [LSW3]display mac-address [LSW3]stp priority 4096 [LSW3]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI DISCARDING NONE 0 GigabitEthernet0/0/2 DESI DISCARDING NONE 0 GigabitEthernet0/0/3 DESI DISCARDING NONE 0 GigabitEthernet0/0/4 DESI DISCARDING NONE [LSW3]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI LEARNING NONE 0 GigabitEthernet0/0/2 DESI LEARNING NONE 0 GigabitEthernet0/0/3 DESI LEARNING NONE 0 GigabitEthernet0/0/4 DESI LEARNING NONE [LSW3]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI LEARNING NONE 0 GigabitEthernet0/0/2 DESI LEARNING NONE 0 GigabitEthernet0/0/3 DESI LEARNING NONE 0 GigabitEthernet0/0/4 DESI LEARNING NONE [LSW3]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE 0 GigabitEthernet0/0/4 DESI FORWARDING NONE [LSW3]display stp interface g0/0/1 brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE
根据LSW2,LSW3都可以看到,端口状态的改变是需要时间的,具体时间可看下图:
做完LSW3的配置后,再看看LSW2,LSW1各端口状态
[LSW2]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE 0 GigabitEthernet0/0/2 ALTE DISCARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW1]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 ROOT FORWARDING NONE 0 GigabitEthernet0/0/2 ALTE DISCARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE [LSW3]display stp brief MSTID Port Role STP State Protection 0 GigabitEthernet0/0/1 DESI FORWARDING NONE 0 GigabitEthernet0/0/2 DESI FORWARDING NONE 0 GigabitEthernet0/0/3 DESI FORWARDING NONE 0 GigabitEthernet0/0/4 DESI FORWARDING NONE
可以看到LSW1和LSW2的g0/0/2端口被禁用了
对于stp端口选择的规则可以看看这篇:
上面也可以看出stp端口角色名:
Root Port(根端口):连接到具有最低优先级的交换机的端口,该端口是距离生成树的根交换机最近的端口。
Designated Port(指定端口):对于每个网络段(LAN),STP选择一个指定端口,该端口用于发送和接收数据包,并作为该网络段连接的交换机的主要路径。
Blocking Port(阻塞端口):处于非活动状态,用于阻止环路的形成。阻塞端口不传递数据,并且不参与生成树的计算。
Non-Designated Port(非指定端口):与指定端口相反,在特定的网络段上不被选为主要路径的端口。
端口分配如下: