优化STP

为什么要提出STP的优化问题?
简单的STP配置虽然可以工作,但可能存在一个突出的问题:收敛时间过长,有时候在全网收敛时间可能超过1分钟以上。所以STP在发展过程中也不断在优化,以提升其工作效率。
 
PortFast, UplinkFast和BackboneFast
这些都是Cisco提出来的特别针对STP问题的解决方案,具体如下:
1)PortFast            

使用环境:在接入(access)端口上使用
优化方法:一旦该端口物理上能工作,立即将其置为“转发”状态
配置命令:
spanning-tree portfast (interface subcommand),
spanning-tree portfast default (global)
要保持一个非trunk模式
debug spanning-tree events(查看生成树的事件)

用show spanning-tree去查看生成树是,type就被定义为edge边缘

在接入的交换机里,全局启用(省事)。
sw(config)#spanning-tree portfast default 
去排除某一个trunk类端口
sw(config-if)#spanning-tree portfast disable

2)UplinkFast     
      
使用环境:在包含多条上行线路的接入层交换机上使用
优化方法:当一个根端口(RP)失去连接时,立即用另一个RP替换,并可立即转发流量,在所有交换机的CAM中触发更新。
配置命令:spanning-tree uplinkfast [max-update-rate rate] (global)

在本地有三个变化
1、有这个的启用命令

2、优先级强制增加到49152
3、cost值增加了3000 

show spanning-tree uplinkfast(看看命令有没有启动)


3)BackboneFast    
使用环境:主要在网络骨干上用来侦测间接的连接失败
优化方法:当RP停止接收Hello时,不需要等待Maxage时间,而是直接查询与RP相连的交换机(使用RLQ BPDU)。
配置命令:spanning-tree backbonefast (global)

工作原理
骨干链路down。backup root发起一个RLQ的查询消息(相当于自己的BPDU消息)。
当这个消息发送到真正的root,root会回应一个。信息也是RLQ(根桥链路查询)
证明了root存活,只是线路出了点问题
中介转发的那台交换机的阻塞接口就会从blk-lis....
这条优化命令仅仅只节约了老化时间20s
这条命令是建议能打的交换机都打上
这条命令也是在全局下启用
sw(config)#spanning-tree backbonefast

show spanning-tree backbonefast(查看它的信息)

小结:
生成树优化命令:
    spanning-tree portfast(基于端口的快速端口。。)
    spanning-tree portfast default(基于全局的。快速端口。排除trunk端口)
    spanning-tree uplinkfast(命令用在接入层上,就是加快备份端口的收敛速度<RP快速切换>,全局配置)
    spanning-tree backbonefast(用在上行链路的检测,所有SW都配,全局配置)


portfast bpduguard:
    交换机端口的portfast bpduguard,是指在交换机的某端口接收到BPDU包后立刻关闭端口,以避免了更大范围的广播风暴的措施;portfast bpduguard要在连接主机的端口上配置;
    基于接口的命令:(c-i)#spanning-tree bpduguard enable ;
    基于全局的命令:(c)#spanning-tree portfast bpduguard default ;
    是指在所有已经启动了portfast端口中,启动bpduguard 。

sw1#show spanning-tree interface e5/0 detail 
 Port 161 (Ethernet5/0) of VLAN0001 is designated forwarding 
   Port path cost 100, Port priority 128, Port Identifier 128.161.
   Designated root has priority 4097, address aabb.cc00.0800
   Designated bridge has priority 32769, address aabb.cc00.0700
   Designated port id is 128.161, designated path cost 200
   Timers: message age 0, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   The port is in the portfast edge mode
   Link type is shared by default
   Bpdu guard is enabled
   BPDU: sent 63, received 0

portfast-bpdufilter:
    要在特定的portfast端口上配置,非PortFast接口无效;
    基于接口的命令:(c-i)#spanning-tree bpdufilter enable ;
    基于全局的命令:(c)#spanning-tree portfast bpdufilter default 。
  

BPDU Guard使具备PortFast特性的端口在接收到BPDU时进入err-disable状态来避免桥接环路,其可在全局或接口下进行配置(默认关闭),可使用errdisable recovery cause bpduguard命令开启端口状态的自动恢复。
 
不同于BPDU防护,BPDU Filter配置于全局/接口模式时,功能有所不同,当启用于PortFast端口模式时,交换机将不发送任何BPDU,并且把接收到的所有BPDU都丢弃;而启用于全局模式时,端口在接收到任何BPDU时,将丢弃PortFast状态和BPDU过滤特性,更改回正常的STP操作,BPDU Filter特性默认关闭。
 
当同时启用bpduguard与bpdufilter时,bpdufilter优先级较高,bpduguard将失效。
 
LOOP Guard主要用来避免阻塞端口错误地过渡到转发状态而产生桥接环路的情况;当交换机在启用loopguard特性的非指定端口上停止接收BPDU时,交换机将使得端口进入STP“不一致环路”(inconsistentports)阻塞状态,当不一致端口再次收到BPDU时,端口将根据BPDU自动过滤到STP状态。通过sh spanning-tree inconsistentports命令可以查看不一致端口状态。loopguard特性默认开启。

原文地址:https://www.cnblogs.com/cyrusxx/p/12615694.html