######本文章是根据华为HCIA-DataCom实验手册中STP实验的练习,按照自己的理解记录下来,如有争议,请联系本人,给予改正,谢谢。
同时也请各位大佬帮忙指正。#########
- 新建拓扑图,添加S1、S2、S3、S4四台交换机,实现链路冗余。
- 分别给四台交换机命名为S1、S2、S3、S4,并且使能交换机STP功能,STP模式更改为STP。
[S1]stp enable
[S1]stp mode stp
[S2]stp enable
[S2]stp mode stp
[S3]stp enable
[S3]stp mode stp
[S4]stp enable
[S4]stp mode stp
- 通过命令dis stp查看交换机STP信息,dis stp brief 查看各端口属性和状态。
[S1]dis stp
-------[CIST Global Info][Mode STP]------- /STP模式
CIST Bridge :32768.4c1f-cc8e-2155 /桥ID
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-cc5d-4315 / 20000 /根桥ID、路径开销
CIST RegRoot/IRPC :32768.4c1f-cc8e-2155 / 0
CIST RootPortId :128.14 /根端口PID
[S1]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 DESI FORWARDING NONE
0 GigabitEthernet0/0/11 DESI FORWARDING NONE
0 GigabitEthernet0/0/13 DESI FORWARDING NONE
0 GigabitEthernet0/0/14 ROOT FORWARDING NONE
[S2]dis stp
-------[CIST Global Info][Mode STP]------- /STP模式
CIST Bridge :32768.4c1f-ccd4-3790 /桥ID
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-cc5d-4315 / 20000 /根桥ID、路径开销
CIST RegRoot/IRPC :32768.4c1f-ccd4-3790 / 0
CIST RootPortId :128.14 /根端口PID
[S2]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 ALTE DISCARDING NONE
0 GigabitEthernet0/0/11 ALTE DISCARDING NONE
0 GigabitEthernet0/0/13 ALTE DISCARDING NONE
0 GigabitEthernet0/0/14 ROOT FORWARDING NONE
[S3]dis stp
-------[CIST Global Info][Mode STP]------- /STP模式
CIST Bridge :32768.4c1f-ccad-1e08 /桥ID
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-cc5d-4315 / 20000 /根桥ID、路径开销
CIST RegRoot/IRPC :32768.4c1f-ccad-1e08 / 0
CIST RootPortId :128.14 /根端口PID
[S3]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ALTE DISCARDING NONE
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
0 GigabitEthernet0/0/3 ROOT FORWARDING NONE
[S4]dis stp
-------[CIST Global Info][Mode STP]------- /STP模式
CIST Bridge :32768.4c1f-cc5d-4315 /桥ID
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-cc5d-4315 / 0 /根桥ID、路径开销
CIST RegRoot/IRPC :32768.4c1f-cc5d-4315 / 0
CIST RootPortId :0.0 /根端口PID
[S4]dis 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
- 通过查看结果可得出STP开启后自动生成树的根桥,各交换机的根端口,各链路的指定端口以及非指定端口。
- 修改桥优先级改变根桥
使用stp root primary命令将S1交换机设置为根桥(优先级为0,且优先级不能修改)
[S1]stp root primary
使用stp root secondary命令将S2交换机设置为备份根桥(优先级为4096,且优先级不能修改)
[S2]stp root secondary
- 通过命令dis stp查看交换机STP信息,dis stp brief 查看各端口属性和状态。
[S1]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :0 .4c1f-cc8e-2155
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 0
CIST RegRoot/IRPC :0 .4c1f-cc8e-2155 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
CIST Root Type :Primary root
[S1]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 DESI FORWARDING NONE
0 GigabitEthernet0/0/11 DESI FORWARDING NONE
0 GigabitEthernet0/0/13 DESI FORWARDING NONE
0 GigabitEthernet0/0/14 DESI FORWARDING NONE
[S2]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :4096 .4c1f-ccd4-3790
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 20000
CIST RegRoot/IRPC :4096 .4c1f-ccd4-3790 / 0
CIST RootPortId :128.10
BPDU-Protection :Disabled
CIST Root Type :Secondary root
[S2]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/10 ROOT FORWARDING NONE
0 GigabitEthernet0/0/11 ALTE DISCARDING NONE
0 GigabitEthernet0/0/13 DESI FORWARDING NONE
0 GigabitEthernet0/0/14 DESI FORWARDING NONE
[S3]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-ccad-1e08
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 20000
CIST RegRoot/IRPC :32768.4c1f-ccad-1e08 / 0
CIST RootPortId :128.1
[S3]dis 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 ALTE DISCARDING NONE
[S4]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc5d-4315
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 20000
CIST RegRoot/IRPC :32768.4c1f-cc5d-4315 / 0
CIST RootPortId :128.1
[S4]dis 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
- 通过查看结果可得出修改S1,S2的桥优先级后所得拓扑的根桥,各交换机的根端口,各链路的指定端口以及非指定端口。
- 将交换机S4的根端口有GE0/0/1改成GE0/0/2
1.根据根端口选举原则:
1)比较各端口到根桥的RPC
2)RPC相等,则比较上行交换机BID
3)若上行交换机BID相同,则比较上行交换机PID
4)若上行交换机PID相同,则比较本地交换机PID
2.通过dis stp命令查看交换机S4的STP信息
[S4]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc5d-4315
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 20000
CIST RegRoot/IRPC :32768.4c1f-cc5d-4315 / 0
CIST RootPortId :128.1
有STP状态信息得知交换机S4到根桥S1的根路径开销为20000
3.所我们通过修改原根端口路径开销的方法修改根端口。
将S4的GE0/0/1的开销值修改为50000
[S4]int g0/0/1
[S4-GigabitEthernet0/0/1]stp cost 50000
4.查看修改后的STP状态信息
[S4]dis stp
-------[CIST Global Info][Mode STP]-------
CIST Bridge :32768.4c1f-cc5d-4315
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 40000
CIST RegRoot/IRPC :32768.4c1f-cc5d-4315 / 0
CIST RootPortId :128.2
BPDU-Protection :Disabled
[S4]dis stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ALTE DISCARDING NONE
0 GigabitEthernet0/0/2 ROOT FORWARDING NONE
0 GigabitEthernet0/0/3 ALTE DISCARDING NONE
由STP状态信息得知S4的根端口已改变为GE0/0/2。,拓扑图如下:
- 修改STP模式为RSTP
- 使用stp mode rstp命令修改STP协议为RSTP协议
[S1]stp mode rstp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S2]stp mode rstp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S3]stp mode rstp
Info: This operation may take a few seconds. Please wait for a moment...done.
[S4]stp mode rstp
Info: This operation may take a few seconds. Please wait for a moment...done.
- 查看各交换机STP状态,以S1为例
-------[CIST Global Info][Mode RSTP]-------
CIST Bridge :0 .4c1f-cc8e-2155
Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20
CIST Root/ERPC :0 .4c1f-cc8e-2155 / 0
CIST RegRoot/IRPC :0 .4c1f-cc8e-2155 / 0
CIST RootPortId :0.0
BPDU-Protection :Disabled
CIST Root Type :Primary root
TC or TCN received :12
TC count per hello :0
STP Converge Mode :Normal
Time since last TC :0 days 0h:1m:56s
Number of TC :24
Last TC occurred :GigabitEthernet0/0/10
----[Port1(GigabitEthernet0/0/1)][DOWN]----
Port Protocol :Enabled
Port Role :Disabled Port
Port Priority :128
Port Cost(Dot1T ) :Config=auto / Active=200000000
Designated Bridge/Port :0.4c1f-cc8e-2155 / 128.1
Port Edged :Config=default / Active=disabled
Point-to-point :Config=auto / Active=false
Transit Limit :147 packets/hello-time
从以上信息看出,模式修改后对生成树无影响。
- 配置边缘端口
将S3的GE0/0/10配置成边缘端口,只连接终端设备。配置成边缘端口后,该端口重要连接终端,up状态,该端口将会以毫秒级由discarding状态变成forwarding状态。
[S3]interface g0/0/10
[S3-interface g0/0/10]stp edged-port enable
配置成边缘端口后,若收到BPDU报文,则边缘端口会立即变为非边缘端口,重新计算生成树。