channel-misconfig (STP) 分析防范
Errdisable 是 cisco 设备的一种机制,该机制会在设备出现 looping、psecure-violation 等情况下 shutdown 或者 suspend 出现问题的端口,同时端口也会的 LED 也会变成橙色。
某台二层设备跟三层连接时,发现做 EC 的某个端口出现了 err-disable 的状态,下面几种方式都可以查看到 error:
#show int G1/0/23 status
Port Name Status Vlan Duplex Speed Type
Gi1/0/23 err-disabled trunk a-full a-1000 10/100/1000BaseTX
#show int G1/0/23
GigabitEthernet1/0/23 is down, line protocol is down (err-disabled)
正常的应该是:
GigabitEthernet1/0/23 is down, line protocol is down (notconnect)
#show interfaces status err-disabled
Port Name Status Reason
Gi1/0/23 err-disabled channel-misconfig (STP)
系统有哪些原因会导致 err-disabled 的状态,可以通过下面的命令查看:
#show errdisable detect
ErrDisable Reason Detection Mode
—————– ——— —-
arp-inspection Enabled port
bpduguard Enabled port
channel-misconfig (STP) Enabled port
community-limit Enabled port
dhcp-rate-limit Enabled port
dtp-flap Enabled port
gbic-invalid Enabled port
inline-power Enabled port
invalid-policy Enabled port
link-flap Enabled port
loopback Enabled port
lsgroup Enabled port
mac-limit Enabled port
pagp-flap Enabled port
port-mode-failure Enabled port
pppoe-ia-rate-limit Enabled port
psecure-violation Enabled port/vlan
security-violation Enabled port
sfp-config-mismatch Enabled port
small-frame Enabled port
storm-control Enabled port
udld Enabled port
vmps Enabled port
可以使用下面命令将其全部禁用掉:
(config)#no errdisable detect cause all
可以通过下面的命令查看有哪些会在 timeout 后会自动恢复,默认情况下,一旦某个端口被置为 err-disabled 的状态,该端口将会一直保持该状态,系统并不会自动的恢复:
#show errdisable recovery
ErrDisable Reason Timer Status
—————– ————–
arp-inspection Disabled
bpduguard Disabled
channel-misconfig (STP) Disabled
dhcp-rate-limit Disabled
dtp-flap Disabled
gbic-invalid Disabled
inline-power Disabled
link-flap Disabled
mac-limit Disabled
loopback Disabled
pagp-flap Disabled
port-mode-failure Disabled
pppoe-ia-rate-limit Disabled
psecure-violation Disabled
security-violation Disabled
sfp-config-mismatch Disabled
small-frame Disabled
storm-control Disabled
udld Disabled
vmps Disabled
Timer interval: 300 seconds
Interfaces that will be enabled at the next timeout:
因此,要使其有自动恢复的功能,需要如下的配置:
#conf t
(config)#errdisable recovery cause channel-misconfig (STP)
还可以设置一下 recovery 的 timer:
(config)#errdisable recovery interval 300
系统会在设置的时间后尝试恢复 err-disabled 状态的端口,如果引起 err-disabled 状态的原因没有解决,该端口会再次的变为 err-disabled,这就会造成 flapping 的状态。
如果之前没有 enable recovery,可以先通过手动的方式修复:
(config)#interface Gi1/0/23
(config-if)# shut
(config-if)# no shut
一般出现 err-disabled 的情况有下面几种:
1. EC 两端的配置不匹配,包括协议商定的类型,PAgP、LACP 的模式,speed,duplex 等。
2. duplex 的问题,这个手动指定两端的 deplex 就好了,可以使用下面的命令查看当前的情况:
# show interfaces Gi1/0/20
然后手工指定:
#configure t
(config)#interface gigabitEthernet1/0/20
(config-if)#speed 1000
(config-if)#duplex full
3. BPDU(bridge protocol data unit) 问题,也就是在同一个接口上做了 portfast 以及 BPDU guard:
#show run interface Gi1/0/20
interface GigabitEthernet 1/0/20
spanning-tree bpduguard enable
spanning-tree portfast enable
end
这个比较好解决,直接:
(config-if)#spanning-tree portfast disable
或者
(config-if)#spanning-tree portfast bpduguard default
4. UDLD(UniDirectional Link Detection) 这个 cisco 私有协议的问题,要么两边都配置,要么都不配置。
5. link-flap,这个大多是物理链路造成的
6. 另外还有诸如 keepalived、port-security violation shutdown、L2pt guard、有问题的 SFPz cable 等也会造成 err-disabled。
下面来分析我们我么遇到的情况,由于出现问题的时候我不在现场,只能根据少量的 log 推断,这是我们三层设备的 log:
# show log
…
%PM-4-ERR_DISABLE: channel-misconfig (STP) error detected on Gi1/0/8, putting Gi1/0/8 in err-disable state
%PM-4-ERR_DISABLE: channel-misconfig (STP) error detected on Po8, putting Gi1/0/8 in err-disable state
%PM-4-ERR_DISABLE: channel-misconfig (STP) error detected on Po8, putting Po8 in err-disable state
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/8, changed state to down
%PM-4-ERR_DISABLE: channel-misconfig (STP) error detected on Gi2/0/8, putting Gi2/0/8 in err-disable state
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet2/0/8, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel8, changed state to down
%LINK-3-UPDOWN: Interface GigabitEthernet1/0/8, changed state to down
%LINK-3-UPDOWN: Interface Port-channel8, changed state to down
%LINK-3-UPDOWN: Interface GigabitEthernet2/0/8, changed state to down
…
可以看到,参与 EC 的端口的配置均做到了 identical,包括 speed, duplex 等。
switchport trunk encapsulation dot1q
switchport mode trunk
!
interface GigabitEthernet1/0/8
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 8 mode on
!
interface GigabitEthernet1/0/8
switchport trunk encapsulation dot1q
switchport mode trunk
channel-group 8 mode on
可以看到, Gi1/0/8, Gi2/0/8(PC 8) 同时都被 down 了,问了下现场的负责人,确实是当时接连 PC8 端口的交换机没有任何配置就直接加电连接了,而偏偏我们的三层设备又都是设置的 on 模式,此时就出现了上面的问题。当我们的机器处于 PAgp 的 on 模式时,交换机不会交换 PAgp 的包,会认为对方也是处于 EC 状态,而恰巧此时我们的对端并没有任何配置,这时候配置了 EC 端的 STP 就会认为出现了 loop,就会将 EC 的两个端口置于 err-disabled 了。
比较好的解决方式就是不要用 on 模式,可以使用 desirable 或者 active 模式:
(config)#interface gigabitethernet1/0/8
(config-if)#channel-group 8 mode desirable non-silent
还有点要注意的是,最好把连接的端口先 shutdown 掉,确保配置完成之后再 no shut。
(如遇erro-disable最好是在interface port-channel X上shutdown再no shutdown)
这位遇到的情况跟我们很类似,他们关于事故采取的措施总结的很到位:
1. no interface po8
2. channel-group 8 mode active
3. no shutdown