Cisco(config)#spanning-tree vlan 10 //激活特定vlan的STP
[Huawei]stp enable //使能交换设备的STP/RSTP功能
Cisco(config)#spanning-tree vlan 10 priority 0 //配置桥优先级,默认为32768,必须是4096的倍数
[Huawei]stp priority 32768 //配置交换设备在系统中的优先级,缺省是32768
Cisco(config)#spanning-tree vlan 10 root primary //配置主根(生成树vlan优先级为24576)
[Huawei]stp root primary //配置当前设备为根桥设备, 缺省不作为任何根桥, 配置后优先级数值自动为0,且不能更改优先级
Cisco(config)#spanning-tree vlan 10 root secondary //配置次根(生成树vlan优先级为28572)
[Huawei]stp root secondary //配置当前交换设备为备份根桥,缺省不作为备份根桥,配置后优先级数值为4096,且不能更改优先级
Cisco(config-if)#spanning-tree vlan 10 cost 10 //设置接口vlan 10的生成树cost值
Cisco(config-if)#spanning-tree cost 10 //设置接口生成树cost值
[Huawei-GigabitEthernet0/0/1]stp cost 10 //设置当前端口的路径开销值:计算方法为legacy时,取值范围是1~200000;为dot1d-1998时,取值范围是1~65535;计算方法为dot1t时,取值范围是1~200000000
Cisco(config-if)#spanning-tree vlan 10 port-priority 64 //设置接口vlan 10的生成树优先级
Cisco(config-if)#spanning-tree port-priority 64 //设置接口生成树优先级
[Huawei-GigabitEthernet0/0/1]stp port priority 128 //配置端口的优先级,缺省是128
Cisco(config-if)#spanning-tree portfast edge //将特定接口激活portfast特性
[Huawei-GigabitEthernet0/0/1]stp edged-port enable //将端口配置成边缘端口
Cisco(config-if)#spanning-tree portfast edge trunk //将特定trunk接口激活portfast特性(该接口不能直连交换机,连接支持trunk封装的路由器或服务器)
Cisco(config)#spanning-tree portfast edge default //将所有非trunk接口激活portfast特性(不触发TCN,可绕过listening和learning状态,加速收敛)
[Huawei]stp edged-port default //配置当前设备上所有端口为边缘端口
Cisco(config)#spanning-tree vlan 10 hello-time 2 //
设置STP的相关时间
[Huawei]stp timer hello 200 //配置设备的Hello Time时间,缺省是200厘秒(2秒)
Cisco(config)#spanning-tree vlan 10 forward-time 15
[Huawei]stp timer forward-delay 1500 //配置设备的Forward Delay时间,缺省是1500厘秒(15秒)
Cisco(config)#spanning-tree vlan 10 max-age 20
[Huawei]stp timer max-age 2000 //配置设备的Max Age时间,缺省是2000厘秒(20秒)
Cisco(config)#spanning-tree mode rapid-pvst //将生成树模式改为RSTP
[Huawei]stp mode rstp //配置交换设备的RSTP工作模式,是缺省模式,MSTP模式兼容STP和RSTP模式
Cisco(config-if)#spanning-tree bpduguard enable //接口配置bpduguard(接口收到BPDU后会立即down掉,防止连接交换机而产生环路,与portfast端口配合使用)
Cisco(config)#spanning-tree portfast edge bpduguard default //全局配置bpduguard
[Huawei]stp bpdu-protection //配置交换设备边缘端口的BPDU保护功能
Cisco(config)#errdisable recovery interval 30 //修改err-disable状态端口恢复时间间隔,默认300s
Cisco(config)#errdisable recovery cause bpduguard //开启因BPDUguard而down掉的接口的自动恢复
[Huawei]error-down auto-recovery cause bpdu-protection interval 100 //配置被error-down的边缘端口自动恢复功能,并设置延迟时间;仅对命令之后发生error-down的端口有效,对此命令之前已经error-down的端口不生效
Cisco(config)#spanning-tree portfast edge bpdufilter default //全局启动后,接口会瞬间发送BPDU,此后不在发送,收到BPDU后会立即都是portfast和BPDUfilter特性,成为一个普通生成树接口,主要在运营商连接客户的交换机上使用
[Huawei]stp bpdu-filter default //配置当前设备上所有端口为BPDU filter端口
Cisco(config-if)#spanning-tree bpdufilter enable //接口不发送也不接收BPDD,
[Huawei-GigabitEthernet0/0/1]stp bpdu-filter enable //配置当前端口为BPDU filter端口
Cisco(config-if)#spanning-tree guard root //针对vlan将端口配置根保护,防止根桥被抢占,一般配置在运营商与客户相连的交换机端口上
[Huawei-GigabitEthernet0/0/1]stp root-protection //配置交换设备的Root保护功能;当端口的角色是指定端口时,配置的Root保护功能才生效;一般只在根桥的端口上配置;配置了Root保护的端口,不可以配置环路保护
Cisco(config-if)#spanning-tree guard loop //接口启用环路保护,如果停止收到BPDU,会切换到loop-inconsistent状态
[Huawei-GigabitEthernet0/0/1]stp loop-protection //配置交换设备根端口或Alternate端口的环路保护功能
思科华为设备STP、RSTP配置命令对比
于 2022-11-28 11:15:10 首次发布
本文档详细介绍了在Cisco和Huawei设备上配置生成树协议(STP/RSTP/MSTP)的步骤,包括激活STP、配置桥优先级、设置根桥、调整接口成本和优先级、启用portfast边缘端口特性、配置BPDU保护功能以及调整STP相关时间参数等,旨在确保网络的稳定性和避免环路问题。
1548

被折叠的 条评论
为什么被折叠?



