Wednesday, January 25, 2012

STP防护机制


STP防护机制介绍 

BPDU Guard:如果接口启用STP PortFast特性,那么当该接口接收到任何BPDU的时候,BPDU Guard能够使其进入“err-disable”状态,需要配置errdisable recovery后才可自动恢复。
SW(config)#[no] spanning-tree portfast bpduguard default //所有配置了PortFast的端口启用BPDU Guard
or
SW(config-if)#spanning-tree portfast
SW(config-if)#spanning-tree bpduguard enable | disable
%SPANTREE-2-RX_PORTFAST: Received BPDU on PortFast enabled port. Disabling FastEthernet0/2.
%PM-4-ERR_DISABLE: bpduguard error detected on Fa0/2, putting Fa0/2 in err-disable state
SW(config)#errdisable recovery cause bpduguard
SW(config)#errdisable recovery interval 30 //30秒后恢复
%PM-4-ERR_RECOVER: Attempting to recover from bpduguard err-disable state on Fa0/2
STP Protect
STP Protect
BPDU Filter:能够防止交换机在启用PortFast特性的接口上发送BPDU,因为PortFast特性的接口一般都是连接到主机,不需要参与STP,减少不必要的BPDU的发送。
  1. 全局配置:如果在全局配置了BPDU Filter,那么接口放弃PortFast特性,转而进入正常的STP操作,转发BPDU。
  2. 接口配置如果是在接口下明确配置BPDU Filter,那么交换机的这个接口将不发送任何BPDU,并且丢弃接收到的所有BPDU。
SW(config)#[no] spanning-tree portfast bpdufilter default
or
SW(config-if)#spanning-tree portfast
SW(config-if)#spanning-tree bpdufilter enable | disable
注意:如果在接口上同时启用BPDU Guard和BPDU Filter,那么BPDU Filter的优先级高于BPDU Guard,所以BPDU Guard将不起作用。
Root Guard:能够将接口强制成为指定接口,防止周围的交换机成为根。如果启用Root Guard的接口收到了更好的BPDU,它将进入“root-inconsistent(根不一致状态)”,类似于listen状态,忽略任何更好的BPDU,不从该接口转发流量。建议在所有的接入层接口上启用Root Guard特性。
SW(config-if)#[no] spanning-tree guard root
SW#show spanning-tree inconsistentports
Name Interface Inconsistency
——————– ———————- ——————
VLAN0001 FastEthernet0/2 Root Inconsistent
Number of inconsistent ports (segments) in the system : 1
%SPANTREE-2-ROOTGUARD_CONFIG_CHANGE: Root guard enabled on port FastEthernet0/2 on VLAN0001.
%SPANTREE-2-ROOTGUARD_BLOCK: Root guard blocking port FastEthernet0/2 on VLAN0001.
Loop Guard:主要是对STP提供额外的由于单向链路故障引起的环路防护(UDLD也可以检测单向链路故障),当阻塞接口接收不到正常的BPDU时,接口不再进行正常的STP收敛,而是进入“loop-inconsistent(环路不一致)”状态,无需配置即可自动恢复。如果使用Loop Guard,Root Guard将会被关闭,不能同时启用。
SW(config)#[no] spanning-tree loopguard default
or
SW(config-if)#[no] spanning-tree guard loop

No comments:

YouTube Channel