华为网络设备 STP
文章目录
STP
- 生成树协议(Spanning Tree Protocol),防止交换环路
修改交换机优先级,系统模式下执行
1
stp priority 0 # 注意是 4096 倍数
显示 stp 状态,任何模式下执行
1 2
dis stp dis stp brief
建议连接 PC 的端口配置为边缘端口,系统模式下执行
1 2 3 4 5
int e0/0/0 stp edged-port enable # 可能需要重启下接口 shutdown undo shutdown
stp 根保护,如果收到较小优先级的 BPDU 报文,则完全阻塞,在根桥每个接口的系统模式下执行,易造成大面积断网,慎用,推荐使用 bpdu 防护
1 2 3 4
int e0/0/1 # 根桥接口 stp root-protection int e0/0/2 # 根桥接口 stp root-protection
stp bpdu 防护,边缘端口收到 stp 报文时,则将该端口阻塞,在系统模式下执行
1 2 3
# 先配置好全部边缘端口 # 开启 stp bpdu 防护 stp bpdu-protection
stp bpdu 防护每隔 30 秒尝试自动恢复
1
error-down auto-recovery cause bpdu-protection interval 30
STP 算法
- 选举根桥(根交换机),先比较优先级,再比较 MAC 地址,越小越优先
- 非根桥选出根端口(距离根交换机最近的端口)
- 其余链路上,优先级或 MAC 地址较大的交换机的端口被阻塞
RSTP
- 快速 stp,stp 升级版
系统模式下执行
1
stp mode rstp
MSTP
- 多生成树协议
- 划分实例,不同实例里运行独立的 stp,默认实例都是 0
系统模式下执行
1 2 3 4 5 6 7 8 9
stp region-configuration region-name xxxx instance 1 vlan 10 # 把 vlan 10 划分到实例 1 中 instance 2 vlan 20 30 # 把 vlan 20 和 30 划分到实例 2 中 active region-configuration # 激活配置 # 根据拓扑,登录相应的交换机,调整 stp 优先级 stp instance 1 priority xxxx stp instance 2 priority xxxx
显示指定实例的 stp 信息,任何模式下执行
1 2
dis stp instance 2 dis stp instance 2 brief
文章作者 Colben
上次更新 2021-02-14