泰涨知识 | 华为生成树协议配置
以下我们通过命令及实例来展示不同生成树协议STP、RSTP及MSTP的配置过程。STP基础配置启用STP/RSTP/MSTPsystem-view进入系统视图 stp enable使能交换设备的STP/RSTP功能缺省情况下设备的STP/RSTP功能处于启用状态。配置STP/RSTP工作模式system-view进入系统视图。stp mode { stp | rstp }配置交换设备的STP/RSTP工作模式缺省情况下交换设备运行MSTP模式MSTP模式兼容STP和RSTP模式配置根桥和备份根桥system-view进入系统视图。stp root primary配置当前设备为根桥设备缺省情况下交换设备不作为任何生成树的根桥。配置后该设备优先级数值自动为0并且不能更改设备优先级。system-view进入系统视图。stp root secondary配置当前交换设备为备份根桥设备缺省情况下交换设备不作为任何生成树的备份根桥配置后该设备优先级数值为4096并且不能更改设备优先级。配置交换设备优先级system-view进入系统视图stp priority 32768 取值0-61440步长4096配置交换设备在系统中的优先级缺省情况下交换设备的优先级取值是32768。配置端口路径开销system-view进入系统视图interface G0/0/1进入接口视图stp cost 200000配置接口的开销配置端口优先级system-view进入系统视图interface G0/0/1进入参与生成树协议计算的接口视图stp port priority 128取值0-240步长16配置端口的优先级缺省情况下交换设备端口的优先级取值是128。配置影响STP拓扑收敛的参数配置STP网络直径交换网络中任意两台终端设备都通过特定路径彼此相连这些路径由一系列的设备构成。网络直径就是指交换网络中任意两台终端设备间的最大设备数。网络直径越大说明网络的规模越大。若网络直径设置不合理可能会引起网络收敛速度慢影响用户的正常通信。配置STP网络直径建议同一环网中的所有设备配置相同的网络直径。system-view进入系统视图。stp bridge-diameter 7配置网络直径。缺省情况下网络直径为7。配置STP定时器配置Forward Delay时间、Hello Time时间以及Max Age时间system-view进入系统视图stp timer forward-delay forward-delay配置设备的Forward Delay时间缺省情况下设备的Forward Delay时间是1500厘秒15秒stp timer hello hello-time配置设备的Hello Time时间缺省情况下设备的Hello Time时间是200厘秒2秒stp timer max-age max-age配置设备的Max Age时间缺省情况下设备的Max Age时间是2000厘秒20秒配置影响RSTP拓扑收敛的参数配置RSTP网络直径同STP配置RSTP超时时间system-view进入系统视图。stp timer-factor 9取值1-10配置未收到上游的BPDU就重新开始生成树计算的超时时间缺省情况下设备未收到上游的BPDU就重新开始生成树计算的超时时间是Hello Timer的9倍配置RSTP定时器同STP配置端口的链路类型system-view进入系统视图。interface G0/0/1进入参与生成树协议计算的接口视图。stp point-to-point { auto | force-false | force-true }配置指定端口的链路类型。缺省情况下指定端口自动识别是否与点对点链路相连点对点链路支持快速收敛。如果当前以太网端口工作在全双工模式则当前端口相连的链路是点到点链路选择参数force-true实现快速收敛。如果当前以太网端口工作在半双工模式可通过执行命令stp point-to-point force-true强制链路类型为点对点链路实现快速收敛。配置端口的最大发送速率system-view进入系统视图。interface interface-type interface-number进入参与生成树协议计算的接口视图。stp transmit-limit 6取值1-255配置端口在单位时间内BPDU的最大发送数目。缺省情况下端口每秒BPDU的最大发送数目为6。如果设备的所有端口都需要配置每秒发送BPDU的最大数目。可以在系统视图下通过执行命令stp transmit-limit系统视图实现。配置设备执行MCheck操作在运行RSTP的设备上如果某个端口和另一台运行STP的设备连接则该端口会自动迁移到STP兼容工作模式。如果运行STP的设备被关机或移走该端口无法自动迁移回RSTP模式此时需要在该端口上执行MCheck操作将端口手动迁移到RSTP模式。以下情况端口无法自动迁回RSTP模式需要在端口上执行MCheck操作将端口手动迁移到RSTP模式在端口模式下执行MCheck操作system-view进入系统视图。interface interface-type interface-number进入参与生成树协议计算的接口视图。stp mcheck执行MCheck操作。在全局模式下执行MCheck操作system-view进入系统视图。stp mcheck执行MCheck操作。配置边缘端口和BPDU报文过滤功能在RSTP里面如果某一个指定端口位于整个网络的边缘即不再与其他交换设备连接而是直接与终端设备直连这种端口叫做边缘端口。配置为边缘端口后端口仍然会发送BPDU报文这可能导致BPDU报文发送到其他网络引起其他网络产生震荡。因此可以配置边缘端口的BPDU报文过滤功能使边缘端口不处理、不发送BPDU报文。在全局模式下配置边缘端口和BPDU报文过滤功能system-view进入系统视图stp edged-port default配置当前设备上所有端口为边缘端口缺省情况下设备的所有端口为非边缘端口stp bpdu-filter default配置当前设备上所有端口为BPDU filter端口缺省情况下设备的所有端口为非BPDU filter端口在端口模式下配置边缘端口和BPDU报文过滤功能system-view进入系统视图interface G0/0/1进入参与生成树协议计算的以太接口视图stp edged-port enable将端口配置成边缘端口缺省情况下设备的所有端口为非边缘端口stp bpdu-filter enable配置当前端口为BPDU filter端口缺省情况下设备的所有端口为非BPDU filter端口配置RSTP/MSTP保护功能配置交换设备的BPDU保护功能system-view进入系统视图。stp bpdu-protection配置交换设备边缘端口的BPDU保护功能。缺省情况下交换设备的BPDU保护功能处于禁用状态。配置交换设备的TC保护功能system-view进入系统视图。stp tc-protection interval interval-value配置设备处理阈值指定数量的拓扑变化报文所需的时间缺省情况下设备处理最大数量的拓扑变化报文所需的时间是Hello Timestp tc-protection threshold threshold配置交换设备在收到TC类型BPDU报文后单位时间内处理TC类型BPDU报文并立即刷新转发表项的阈值缺省情况下设备在指定时间内处理拓扑变化报文的最大数量是1。注释配置后在stp tc-protection interval指定的时间内设备只会处理stp tc-protection threshold指定数量的拓扑变化报文对于其他的报文会延迟处理所以可能会影响生成树的收敛速度。例如时间设定为10秒阈值设定为5则设备收到拓扑变化报文后在10秒内只会处理最开始收到的5个拓扑变化报文对于后面收到的报文则会等10秒超时后再统一处理。配置端口的Root保护功能system-view进入系统视图。interface interface-type interface-number进入参与生成树协议计算的接口视图。stp root-protection配置交换设备的Root保护功能。缺省情况下端口的Root保护功能处于去使能状态。当端口的角色是指定端口时配置的Root保护功能才生效。配置了根保护的端口不可以配置环路保护。配置端口的环路保护功能system-view进入系统视图。interface interface-type interface-number进入参与生成树协议计算的接口视图。stp loop-protection配置交换设备根端口或Alternate端口的环路保护功能。注释由于Alternate端口是根端口的备份端口如果交换设备上有Alternate端口需要在根端口和Alternate端口上同时配置环路保护。配置了根保护的端口不可以配置环路保护。配置MSTP基本功能配置MSTP工作模式同STP华为交换设备默认为MSTP模式配置MST域并激活MST域即多生成树域是由交换网络中的多台交换设备以及它们之间的网段所构成。这些交换设备启动MSTP后具有相同域名、相同VLAN到生成树映射配置和相同MSTP修订级别配置并且物理上直接相连。一个交换网络可以存在多个MST域用户可以通过MSTP配置命令把多台交换设备划分在同一个MST域内。注释当两台交换设备的以下配置都相同时这两台交换设备属于同一个MST域。MST域的域名。多生成树实例和VLAN的映射关系MST域的修订级别system-view进入系统视图stp region-configuration进入MST域视图region-name name配置MST域的域名缺省情况下MST域的域名等于交换设备桥MAC的MAC地址instance instance-id vlan { vlan-id1 [ to vlan-id2 ] }1-10配置多生成树实例和VLAN的映射关系缺省情况下MST域内所有的VLAN都映射到生成树实例0revision-level level配置MST域的MSTP修订级别缺省情况下MST域的MSTP修订级别为0active region-configuration激活MST域的配置使域名、VLAN映射表和MSTP修订级别生效。如果不执行本操作以上配置的域名、VLAN映射表和MSTP修订级别无法生效。配置根桥和备份根桥同STP配置交换设备在指定生成树实例中的优先级同STP配置端口在指定生成树实例中的路径开销同STP配置端口在指定生成树实例中的优先级同STP配置MST域的最大跳数system-view进入系统视图。stp max-hops hop配置MST域的最大跳数。缺省情况下MST域的最大跳数为20。配置MSTP支持和其他制造商设备互通的参数为了实现与其他制造商设备的互通需要在华为公司运行MSTP的设备上配置一些参数以确保通信畅通。配置端口Proposal/Agreement机制的迁移方式system-view进入系统视图。interface G0/0/1进入以太接口视图。stp no-agreement-check配置端口使用普通的快速迁移方式。缺省情况下端口使用增强的快速迁移机制。配置端口收发MSTP协议的报文格式MSTP协议报文存在两种格式一种为dot1s即IEEE802.1s规定的报文格式另一种为legacy是一种私有报文格式system-view进入系统视图。interface interface-type interface-number进入以太接口视图。stp compliance { auto | dot1s | legacy }配置端口协议报文格式。缺省情况下MSTP报文收发格式为auto模式。使能摘要侦听功能当华为设备与其他制造商的设备互连时在域名、修订级别、VLAN实例映射表全都一致的情况下由于双方BPDU报文密钥不一致会导致两台设备不能正常互通在这种情况下需要在交换设备上使能摘要侦听功能。在MST域中的交换设备上进行以下配置实现华为设备的BPDU报文密钥与其他制造商设备的BPDU报文密钥一致。system-view进入系统视图。interface G0/0/1进入以太接口视图。stp config-digest-snoop使能端口上配置摘要侦听的功能。配置举例配置MSTP单域多实例负载分担如下图局域网内部互访实现同vlan互访不走次优路径,同时保证每一条链路都可以承载流量如果局域网内部任何一条链路故障都可以保证有备份链路为了提高用户的上网质量希望链接终端的接口可以快速收敛。VLAN10互访路径为SW1-SW3VLAN20互访路径为SW2-SW4VLAN30互访路径为SW1-SW2VLAN40互访路径为SW3-SW4SW1配置如下sysname SW1#vlan batch 10 30 40#stp instance 1 priority 0stp instance 3 priority 4096#stp region-configurationregion-name 1234revision-level 1234instance 1 vlan 10instance 2 vlan 20instance 3 vlan 30instance 4 vlan 40active region-configuration#interface GigabitEthernet0/0/1port link-type accessport default vlan 30stp edged-port enable#interface GigabitEthernet0/0/2port link-type accessport default vlan 10stp edged-port enable#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 10 20 30 40#interface GigabitEthernet0/0/4port link-type trunkport trunk allow-pass vlan 10 20 30 40#SW2配置如下sysname SW2#vlan batch 10 20 30 40#stp instance 2 priority 4096stp instance 3 priority 0#stp region-configurationregion-name 1234revision-level 1234instance 1 vlan 10instance 2 vlan 20instance 3 vlan 30instance 4 vlan 40active region-configuration#interface GigabitEthernet0/0/1port link-type accessport default vlan 20stp edged-port enable#interface GigabitEthernet0/0/2port link-type accessport default vlan 30stp edged-port enable#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 10 20 30 40#interface GigabitEthernet0/0/4port link-type trunkport trunk allow-pass vlan 10 20 30 40#SW3配置如下sysname SW3#vlan batch 10 20 30 40#stp region-configurationregion-name 1234revision-level 1234instance 1 vlan 10instance 2 vlan 20instance 3 vlan 30instance 4 vlan 40active region-configuration#interface GigabitEthernet0/0/1port link-type accessport default vlan 40stp edged-port enable#interface GigabitEthernet0/0/2port link-type accessport default vlan 10stp edged-port enable#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 10 20 30 40#interface GigabitEthernet0/0/4port link-type trunkport trunk allow-pass vlan 10 20 30 40#SW4配置如下sysname SW4#vlan batch 10 20 30 40#stp instance 2 priority 0stp instance 4 priority 4096#stp region-configurationregion-name 1234revision-level 1234instance 1 vlan 10instance 2 vlan 20instance 3 vlan 30instance 4 vlan 40active region-configuration#interface GigabitEthernet0/0/1port link-type accessport default vlan 40stp edged-port enable#interface GigabitEthernet0/0/2port link-type accessport default vlan 20stp edged-port enable#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 10 20 30 40#interface GigabitEthernet0/0/4port link-type trunkport trunk allow-pass vlan 10 20 30 40#配置MSTPVRRP组合组网示例用户希望在存在冗余备份链路的同时消除网络中的环路在一条上行链路断开的时候流量能切换到另外一条上行链路转发还能合理利用网络带宽。如下图R1配置如下sysname R1#bfd#interface GigabitEthernet0/0/0ip address 10.1.12.1 255.255.255.0#interface GigabitEthernet0/0/1ip address 10.1.11.1 255.255.255.0#interface GigabitEthernet0/0/2ip address 10.1.13.1 255.255.255.0#bfd 11 bind peer-ip 10.1.11.11 source-ip 10.1.11.1 autocommit#ospf 1 router-id 1.1.1.1default-route-advertisearea 0.0.0.0network 10.1.11.1 0.0.0.0network 10.1.12.1 0.0.0.0#ip route-static 0.0.0.0 0.0.0.0 10.1.13.3#R2配置如下sysname R2#interface GigabitEthernet0/0/0ip address 10.1.12.2 255.255.255.0#interface GigabitEthernet0/0/1ip address 10.1.22.2 255.255.255.0#interface GigabitEthernet0/0/2ip address 10.1.23.2 255.255.255.0#ospf 1 router-id 2.2.2.2default-route-advertisearea 0.0.0.0network 10.1.12.2 0.0.0.0network 10.1.22.2 0.0.0.0#ip route-static 0.0.0.0 0.0.0.0 10.1.23.3#R3配置如下sysname R3#interface GigabitEthernet0/0/0ip address 10.1.13.3 255.255.255.0#interface GigabitEthernet0/0/1ip address 10.1.23.3 255.255.255.0#interface GigabitEthernet0/0/2#interface LoopBack0ip address 10.3.3.3 255.255.255.255#ip route-static 0.0.0.0 0.0.0.0 10.1.13.1ip route-static 0.0.0.0 0.0.0.0 10.1.23.2#SW1配置如下sysname SW1#vlan batch 10 20 30#stp instance 10 priority 0stp instance 20 priority 4096#stp region-configurationregion-name 12revision-level 12instance 10 vlan 10instance 20 vlan 20active region-configuration#bfd#interface Vlanif10ip address 10.1.1.251 255.255.255.0vrrp vrid 10 virtual-ip 10.1.1.254vrrp vrid 10 priority 200vrrp vrid 10 track interface GigabitEthernet0/0/1 reduced 100vrrp vrid 10 track bfd-session session-name 11 reduced 100#interface Vlanif20ip address 10.2.1.251 255.255.255.0vrrp vrid 20 virtual-ip 10.2.1.254vrrp vrid 20 priority 150#interface Vlanif30ip address 10.1.11.11 255.255.255.0#interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 10#interface GigabitEthernet0/0/2port link-type trunkport trunk allow-pass vlan 10 20#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 20#interface GigabitEthernet0/0/4port link-type accessport default vlan 30#bfd 11 bind peer-ip 10.1.11.1 source-ip 10.1.11.11 autocommit#ospf 1 router-id 11.11.11.11silent-interface Vlanif10silent-interface Vlanif20area 0.0.0.0network 10.1.11.11 0.0.0.0network 10.1.1.251 0.0.0.0network 10.2.1.251 0.0.0.0#SW2配置如下sysname SW2#vlan batch 10 20 30#stp instance 10 priority 4096stp instance 20 priority 0#stp region-configurationregion-name 12revision-level 12instance 10 vlan 10instance 20 vlan 20active region-configuration#interface Vlanif10ip address 10.1.1.252 255.255.255.0vrrp vrid 10 virtual-ip 10.1.1.254vrrp vrid 10 priority 150#interface Vlanif20ip address 10.2.1.252 255.255.255.0vrrp vrid 20 virtual-ip 10.2.1.254vrrp vrid 20 priority 200vrrp vrid 20 track interface GigabitEthernet0/0/1 reduced 100#interface Vlanif30ip address 10.1.22.22 255.255.255.0#interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 20#interface GigabitEthernet0/0/2port link-type trunkport trunk allow-pass vlan 10 20#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 10#interface GigabitEthernet0/0/4port link-type accessport default vlan 30#ospf 1 router-id 22.22.22.22silent-interface Vlanif10silent-interface Vlanif20area 0.0.0.0network 10.1.22.22 0.0.0.0network 10.2.1.252 0.0.0.0network 10.1.1.252 0.0.0.0#SW3配置如下sysname SW3#vlan batch 10#stp region-configurationregion-name 12revision-level 12instance 10 vlan 10instance 20 vlan 20active region-configuration#interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 10#interface GigabitEthernet0/0/2port link-type accessport default vlan 10stp edged-port enable#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 10#interface GigabitEthernet0/0/4port link-type accessport default vlan 10stp edged-port enable#SW4配置如下sysname SW4#vlan batch 10 20#stp region-configurationregion-name 12revision-level 12instance 10 vlan 10instance 20 vlan 20active region-configuration#interface GigabitEthernet0/0/1port link-type trunkport trunk allow-pass vlan 20#interface GigabitEthernet0/0/2port link-type accessport default vlan 20stp edged-port enable#interface GigabitEthernet0/0/3port link-type trunkport trunk allow-pass vlan 20#interface GigabitEthernet0/0/4port link-type accessport default vlan 20stp edged-port enable#