logo

   上海鸣沃信息科技有限公司Shanghai MingWo Infor  Tec CO., LTD.

  技术文档
您当前所在的位置是:技术文档

核心交换机合规配置RSTP 演示

2025/8/13 17:33:02

信息内容
配置RSTP功能示例

组网需求
在一个复杂的网络中,网络规划者由于冗余备份的需要,一般都倾向于在设备之间部署多条物理链路,其中一条作主用链路,其他链路作备份。这样就难免会形成环形网络,若网络中存在环路,可能会引起广播风暴和MAC表项被破坏。

网络规划者规划好网络后,可以在网络中部署RSTP协议预防环路。当网络中存在环路,RSTP通过阻塞某个端口以达到破除环路的目的。如图14-19所示,当前网络中存在环路,SwitchA、SwitchB、SwitchC和SwitchD都运行RSTP,通过彼此交互信息发现网络中的环路,并有选择的对某个端口进行阻塞,最终将环形网络结构修剪成无环路的树形网络结构,从而防止报文在环形网络中不断循环,避免设备由于重复接收相同的报文造成处理能力下降。

图14-19 配置RSTP功能组网图



配置思路
采用以下思路配置RSTP功能:
在处于环形网络中的交换设备上配置RSTP基本功能,包括:
配置环网中的设备生成树协议工作在RSTP模式。

配置根桥和备份根桥设备。

配置端口的路径开销值,实现将该端口阻塞。

使能RSTP,实现破除环路。与PC相连的端口不用参与RSTP计算,将其设置为边缘端口。

配置保护功能,实现对设备或链路的保护。例如:在根桥设备的指定端口配置根保护功能。

操作步骤
配置RSTP基本功能
配置环网中的设备生成树协议工作在RSTP模式

# 配置SwitchA的RSTP工作模式。

system-view
[HUAWEI] sysname SwitchA
[SwitchA] stp mode rstp
# 配置交换设备SwitchB的RSTP工作模式。

system-view
[HUAWEI] sysname SwitchB
[SwitchB] stp mode rstp
# 配置交换设备SwitchC的RSTP工作模式。

system-view
[HUAWEI] sysname SwitchC
[SwitchC] stp mode rstp
# 配置交换设备SwitchD的RSTP工作模式。

system-view
[HUAWEI] sysname SwitchD
[SwitchD] stp mode rstp
配置根桥和备份根桥设备

# 配置SwitchA为根桥。

[SwitchA] stp root primary
# 配置SwitchD为备份根桥。

[SwitchD] stp root secondary
配置端口的路径开销值,实现将该端口阻塞

端口路径开销值取值范围由路径开销计算方法决定,这里选择使用华为计算方法为例,配置将被阻塞端口的路径开销值为20000。

同一网络内所有交换设备的端口路径开销应使用相同的计算方法。

# 配置SwitchA的端口路径开销计算方法为华为计算方法。

[SwitchA] stp pathcost-standard legacy
# 配置SwitchB的端口路径开销计算方法为华为计算方法。

[SwitchB] stp pathcost-standard legacy
# 配置SwitchC端口GigabitEthernet1/0/1端口路径开销值为20000。

[SwitchC] stp pathcost-standard legacy
[SwitchC] interface gigabitethernet 1/0/1
[SwitchC-GigabitEthernet1/0/1] stp cost 20000
[SwitchC-GigabitEthernet1/0/1] quit
# 配置SwitchD的端口路径开销计算方法为华为计算方法。

[SwitchD] stp pathcost-standard legacy
使能RSTP,实现破除环路

将与PC机相连的端口设置为边缘端口

# 配置SwitchB端口GigabitEthernet1/0/2为边缘端口。

[SwitchB] interface gigabitethernet 1/0/2
[SwitchB-GigabitEthernet1/0/2] stp edged-port enable
[SwitchB-GigabitEthernet1/0/2] quit
(可选)配置SwitchB的BPDU保护功能。

[SwitchB] stp bpdu-protection
# 配置SwitchC端口GigabitEthernet1/0/2为边缘端口。

[SwitchC] interface gigabitethernet 1/0/2
[SwitchC-GigabitEthernet1/0/2] stp edged-port enable
[SwitchC-GigabitEthernet1/0/2] quit
(可选)配置SwitchC的BPDU保护功能。

[SwitchC] stp bpdu-protection


设备全局使能RSTP

# 设备SwitchA全局使能RSTP。

[SwitchA] stp enable
# 设备SwitchB全局使能RSTP。

[SwitchB] stp enable
# 设备SwitchC全局使能RSTP。

[SwitchC] stp enable
# 设备SwitchD全局使能RSTP。

[SwitchD] stp enable
配置保护功能,如在根桥设备的指定端口配置根保护功能
# 在SwitchA端口GigabitEthernet1/0/1上配置根保护功能。

[SwitchA] interface gigabitethernet 1/0/1
[SwitchA-GigabitEthernet1/0/1] stp root-protection
[SwitchA-GigabitEthernet1/0/1] quit
# 在SwitchA端口GigabitEthernet1/0/2上配置根保护功能。

[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] stp root-protection
[SwitchA-GigabitEthernet1/0/2] quit
验证配置结果
经过以上配置,在网络计算稳定后,执行以下操作,验证配置结果。

# 在SwitchA上执行display stp brief命令,查看端口状态和端口的保护类型,结果如下:

[SwitchA] display stp brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet1/0/1        DESI  FORWARDING      ROOT
   0    GigabitEthernet1/0/2        DESI  FORWARDING      ROOT
将SwitchA配置为根桥后,与SwitchB、SwitchD相连的端口GigabitEthernet1/0/2和GigabitEthernet1/0/1在生成树计算中被选举为指定端口,并在指定端口上配置根保护功能。

# 在SwitchB上执行display stp interface gigabitethernet 1/0/1 brief命令,查看端口GigabitEthernet1/0/1状态,结果如下:

[SwitchB] display stp interface gigabitethernet 1/0/1 brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet1/0/1        DESI  FORWARDING      NONE      
端口GigabitEthernet1/0/1在生成树选举中成为指定端口,处于Forwarding状态。

# 在SwitchC上执行display stp brief命令,查看端口状态,结果如下:

[SwitchC] display stp brief
 MSTID  Port                        Role  STP State     Protection
   0    GigabitEthernet1/0/1        ALTE  DISCARDING      NONE     
   0    GigabitEthernet1/0/2        DESI  FORWARDING      BPDU     
   0    GigabitEthernet1/0/3        ROOT  FORWARDING      NONE     
端口GE1/0/1在生成树选举中成为Alternate端口,处于DISCARDING状态。

端口GE1/0/3在生成树选举中成为根端口,处于FORWARDING状态。

配置文件
SwitchA的配置文件

#
sysname SwitchA                 
#                                
stp mode rstp                   
stp instance 0 root primary     
stp pathcost-standard legacy
#                                
interface GigabitEthernet1/0/1  
 stp root-protection             
#                                
interface GigabitEthernet1/0/2  
 stp root-protection             
#
return
SwitchB的配置文件

#                                
sysname SwitchB               
#                                
stp mode rstp                   
stp bpdu-protection
stp pathcost-standard legacy
#                             
interface GigabitEthernet1/0/2        
 stp edged-port enable
#                                
return                    
SwitchC的配置文件

#                                
sysname SwitchC                                   
#                                
stp mode rstp                   
stp bpdu-protection
stp pathcost-standard legacy
#                                
interface GigabitEthernet1/0/1       
 stp instance 0 cost 20000       
#                                
interface GigabitEthernet1/0/2        
 stp edged-port enable
#                                
return           
SwitchD的配置文件

#                                
sysname SwitchD                        
#                                
stp mode rstp                   
stp instance 0 root secondary   
stp pathcost-standard legacy
#                                
return 
[←]S7700 V200R024C10 配置GVRP示例 [→]VBST配置注意事项实例

                                                                                                   沪ICP备11005944号| 网站所有©上海鸣沃信息科技有限公司

华为防火墙 华为交换机 华为无线 华为路由器 华为租赁 H3C交换机 H3C防火墙 H3C无线 H3C路由器 H3C租赁 思科交换机 思科防火墙 思科无线 思科路由器 思科租赁  CISCO交换机租赁 CISCO防火墙租赁