目录
Cisco 设备
#sw1为主根交换机,sw2为副根交换机,sw3为接入层交换机
# 配置,在sw1中,配置vlan10,vlan20,为主根,vlan30,vlan40,为次根
# 在全局配置模式下:spanning-tree vlan 10 priority 0
spanning-tree-vlan 20 priority 0
spanning-tree-vlan 30 priority 4096
spanning-tree-vlan 40 priority 4096 // #配置生成树的主根时,设置它的优先级,优先级默认是32768,比它小就越靠谱,#优先级默认是4096的倍数
#
# 配置,在sw2中,配置vlan30,vlan40,为主根,vlan10,vlan20,为次根
# 在全局配置模式下:spanning-tree vlan 10 priority 4096
spanning-tree-vlan 20 priority 4096
spanning-tree-vlan 30 priority 0
spanning-tree-vlan 40 priority 0 // #配置生成树的主根时,设置它的优先级,优先级默认是32768,比它小就越靠谱,#优先级默认是4096的倍数
spanning-tree portfast //启用端口快速收敛
spanning-tree bpduguard enable //启用BPDU防护
spanning-tree bpdufilter enable //启用BPDU过滤
spanning-tree guard root //启用根防护
spanning-tree guard loop //启用环路防护
udld port aggressive //启用UDLD
生成树特性全局配置:
spanning-tree uplinkfast 启用uplinkfast特性
spanning-tree backbonefast 启用backbonefast
华为设备
stp mode stp/rstp /mstp
# 配置RouterA为根桥。
[RouterA] stp root primary 或者 stp instance 0 root primary
# 配置SwitchA为备份根桥。
[SwitchA] stp root secondary
[SwitchC] interface Ethernet0/0/4
[SwitchC-Ethernet0/0/4] stp cost 200000 修改开销值
MST/MSTP 配置
[S1]stp mo mstp <!--将交换机配置成MSTP模式-->
[S1]stp region-configuration <!--进入MSTP配置模式-->
[S1-mst-region]region-name lv <!--配置域名为“lv”-->
[S1-mst-region]revision-level 1 <!--配置版本等级为“1”-->INTEGER<0-65535>
[S1-mst-region]instance 1 vlan 10 <!--将vlan 10加入实例1中-->
[S1-mst-region]instance 2 vlan 20 <!--将vlan 20加入实例2中-->
[S1-mst-region]active region-configuration <!--激活配置(必须配置)-->
[S1-mst-region]quit <!--退出配置模式-->
[S1]stp instance 1 root primary <!--配置此交换机为实例1的主根-->
[S1]stp instance 2 root secondary <!--配置此交换机为实例2的备根-
BPDU保护
[Huawei]stp bpdu-protection #开启BPDU保护
根保护
[Huawei]in g0/0/1 #进入指定端口
[Huawei-GigabitEthernet0/0/1]stp root-protection #开启根保护
环路保护
[Huawei]in g0/0/1 #进入根端口
[Huawei-GigabitEthernet0/0/1]stp loop-protection #启用环路保护功能
TC保护
[Huawei]stp tc-protection threshold 3 #指定阈值为3。