技术论坛
配置STP 功能示例
更新时间:2022-09-07
配置stp组网图
配置思路
采用以下思路配置STP功能:
1. 在处于环形网络中的交换设备上配置STP基本功能,包括:
a. 配置环网中的设备生成树协议工作在STP模式。
b. 配置根桥和备份根桥设备。
c. 配置端口的路径开销值,实现将该端口阻塞。
d. 使能STP,实现破除环路。
说明 :与PC机相连的端口不用参与STP计算,建议将其去使能STP。
操作步骤
步骤1 配置STP基本功能
1. 配置环网中的设备生成树协议工作在STP模式
# 配置交换设备SwitchA的STP工作模式。
<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] stp mode stp
# 配置交换设备SwitchB的STP工作模式。
<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] stp mode stp
# 配置交换设备SwitchC的STP工作模式。
<HUAWEI> system-view
[HUAWEI] sysname SwitchC
[SwitchC] stp mode stp
# 配置交换设备SwitchD的STP工作模式。
<HUAWEI> system-view
[HUAWEI] sysname SwitchD
[SwitchD] stp mode stp
2. 配置根桥和备份根桥设备
# 配置SwitchA为根桥。
[SwitchA] stp root primary
# 配置SwitchD为备份根桥。
[SwitchD] stp root secondary
3. 配置端口的路径开销值,实现将该端口阻塞
说明
l 端口路径开销值取值范围由路径开销计算方法决定,这里选择使用华为计算方法为例,
配置将被阻塞端口的路径开销值为20000。
l 同一网络内所有交换设备的端口路径开销应使用相同的计算方法。
# 配置SwitchA的端口路径开销计算方法为华为计算方法。
[SwitchA] stp pathcost-standard legacy
# 配置SwitchB的端口路径开销计算方法为华为计算方法。
[SwitchB] stp pathcost-standard legacy
# 配置SwitchC端口GigabitEthernet0/0/1端口路径开销值为20000。
[SwitchC] stp pathcost-standard legacy
[SwitchC] interface gigabitethernet 0/0/1
[SwitchC-GigabitEthernet0/0/1] stp cost 20000
[SwitchC-GigabitEthernet0/0/1] quit
# 配置SwitchD的端口路径开销计算方法为华为计算方法。
[SwitchD] stp pathcost-standard legacy
4. 使能STP,实现破除环路
l 将与PC机相连的端口去使能STP
# 配置SwitchB端口GigabitEthernet0/0/2的STP去使能。
[SwitchB] interface gigabitethernet 0/0/2
[SwitchB-GigabitEthernet0/0/2] stp disable
[SwitchB-GigabitEthernet0/0/2] quit
# 配置SwitchC端口GigabitEthernet0/0/2的STP去使能。
[SwitchC] interface gigabitethernet 0/0/2
[SwitchC-GigabitEthernet0/0/2] stp disable
[SwitchC-GigabitEthernet0/0/2] quit
l 设备全局使能STP
# 设备SwitchA全局使能STP。
[SwitchA] stp enable
# 设备SwitchB全局使能STP。
[SwitchB] stp enable
# 设备SwitchC全局使能STP。
[SwitchC] stp enable
# 设备SwitchD全局使能STP。
[SwitchD] stp enable
步骤2 验证配置结果
经过以上配置,在网络计算稳定后,执行以下操作,验证配置结果。
# 在SwitchA上执行display stp brief命令,查看端口状态和端口的保护类型,结果如下:
[SwitchA] display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
0 GigabitEthernet0/0/2 DESI FORWARDING NONE
将SwitchA配置为根桥后,与SwitchB、SwitchD相连的端口GigabitEthernet0/0/2和 GigabitEthernet0/0/1在生成树计算中被选举为指定端口。
# 在SwitchB上执行display stp interface gigabitethernet 0/0/1 brief命令,查看端口GigabitEthernet0/0/1状态,结果如下:
[SwitchB] display stp interface gigabitethernet 0/0/1 brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 DESI FORWARDING NONE
端口GigabitEthernet0/0/1在生成树选举中成为指定端口,处于Forwarding状态。
# 在SwitchC上执行display stp brief命令,查看端口状态,结果如下:
[SwitchC] display stp brief
MSTID Port Role STP State Protection
0 GigabitEthernet0/0/1 ALTE DISCARDING NONE
0 GigabitEthernet0/0/3 ROOT FORWARDING NONE
端口GigabitEthernet0/0/3在生成树选举中成为根端口,处于FORWARDING状态。
端口GigabitEthernet0/0/1在生成树选举中成为Alternate端口,处于DISCARDING状态。
配置文件
1、 SwitchA的配置文件
#
sysname SwitchA
#
stp mode stp
stp instance 0 root primary
stp pathcost-standard legacy
#
return
2、 SwitchB的配置文件
#
sysname SwitchB
#
stp mode stp
stp pathcost-standard legacy
#
interface GigabitEthernet0/0/2
stp disable
#
return
3、 SwitchC的配置文件
#
sysname SwitchC
#
stp mode stp
stp pathcost-standard legacy
#
interface GigabitEthernet0/0/1
stp instance 0 cost 20000
#
interface GigabitEthernet0/0/2
stp disable
#
return
4、 SwitchD的配置文件
#
sysname SwitchD
#
stp mode stp
stp instance 0 root secondary
stp pathcost-standard legacy
#
return