多业务VLAN共用一条链路成环不敢整个关口?华为Loop Detection按VLAN退出只断成环的
二层网络最怕环路。广播、组播、未知单播在环里一轮轮复制,几秒钟就能把整台交换机打满,全网跟着瘫。前面聊过下挂网络成环的处理——检测到就把问题口关掉。但实际网络里还有更讲究的场景:汇聚交换机的上联口同时承载十几个业务 VLAN,大家共用同一条链路。这时候 VLAN 8 成了环,你把整个接口 shutdown,VLAN 10 到 20 里没成环的业务全部陪葬,一个部门接错网线,全楼断网。
华为交换机的 Loop Detection 给了更精细的选项:处理动作除了关闭接口,还可以配置 Quitvlan——检测到哪个 VLAN 成环,接口只退出那个 VLAN,其余 VLAN 照常转发。共用链路的场景,这一档动作刚好对症。
先把检测原理说清。Loop Detection 从接口周期性发送检测报文,检查报文是否返回本设备,不要求收发接口是同一个口:检测报文从发出去的接口收到,说明该接口自环或下挂网络成环;检测报文被本设备上的其他接口收到,说明该接口或设备所在的网络中存在环路——本篇讲的正是后一种,成环点不在你下挂的接入层,而在你这台设备所处的二层网络里。检测到环路后,设备向网管上报告警并记录日志,再按配置把接口置于受控状态;受控后仍继续发检测报文,恢复时间内收不到报文就认为环路消除,接口自动恢复正常。处理动作共有五种:Trap(只告警不处理)、Block(阻塞接口)、No learning(停止 MAC 学习)、Shutdown(关闭接口)、Quitvlan(退出成环 VLAN)。
有两条使用纪律要记住:Loop Detection 与 STP/RSTP/MSTP、ERPS、RRPP 等环网功能冲突,使能了 Loop Detection 的接口不要再配环网功能(本例接口下因此执行了 stp disable);它只发 Tagged 检测报文,只能基于 VLAN 检测。另外 Loop Detection 是单节点检测技术,不具备网络级破环能力,别指望它替代环网协议。
组网与配置
示例网络为二层组网,Switch 是汇聚交换机,接口 GE1/0/0 和 GE2/0/0 上联,各交换机允许 VLAN 10~20 通过。因人员流动性大、拓扑变更频繁,变更中连接或配置失误就可能让 VLAN 10~20 里出环。VLAN 数超过 8 个,配置 Loop Detection 对 VLAN 10~20 逐一检测,处理动作选 Quitvlan。
第一步,使能全局与 VLAN 的检测功能:
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] loop-detection enable //使能全局的Loop Detection功能
[Switch] vlan batch 10 to 20
[Switch] loop-detection enable vlan 10 to 20 //配置设备对VLAN10到VLAN20下的所有接口进行环路检测
第二步,配置检测报文发送周期:
[Switch] loop-detection interval-time 10 //配置Loop Detection检测报文的发送周期为10s
第三步,打开告警开关,让设备能发 Trap 报文:
[Switch] snmp-agent trap enable feature-name ldttrap //打开Loop Detection的告警开关,使设备具有发送Loop Detection Trap报文的功能
第四步,两个上联口配置链路类型并指定处理动作:
[Switch] interface gigabitethernet 1/0/0
[Switch-GigabitEthernet1/0/0] port link-type hybrid //V200R005C00及以后版本交换机接口的缺省链路类型不是Hybrid类型,用户可根据需要执行命令port link-type hybrid配置接口的链路类型为Hybrid
[Switch-GigabitEthernet1/0/0] stp disable //去使能接口的STP功能
[Switch-GigabitEthernet1/0/0] port hybrid tagged vlan 10 to 20
[Switch-GigabitEthernet1/0/0] loop-detection mode port-quitvlan //配置Loop Detection检测到环路时对接口的处理动作为Quitvlan
[Switch-GigabitEthernet1/0/0] quit
[Switch] interface gigabitethernet 2/0/0
[Switch-GigabitEthernet2/0/0] port link-type hybrid
[Switch-GigabitEthernet2/0/0] stp disable //去使能接口的STP功能
[Switch-GigabitEthernet2/0/0] port hybrid tagged vlan 10 to 20
[Switch-GigabitEthernet2/0/0] loop-detection mode port-quitvlan //配置Loop Detection检测到环路时对接口的处理动作为Quitvlan
[Switch-GigabitEthernet2/0/0] quit
第五步,配置受控接口的恢复时间,环路消失后接口在时限内自动回正常:
[Switch] interface gigabitethernet 1/0/0
[Switch-GigabitEthernet1/0/0] loop-detection recovery-time 30 //配置受控接口的恢复时间为30秒
[Switch-GigabitEthernet1/0/0] quit
[Switch] interface gigabitethernet 2/0/0
[Switch-GigabitEthernet2/0/0] loop-detection recovery-time 30 //配置受控接口的恢复时间为30秒
[Switch-GigabitEthernet2/0/0] quit
最终设备上的配置文件:
#
sysname Switch
#
vlan batch 10 to 20
#
loop-detection enable
loop-detection interval-time 10
loop-detection enable vlan 10 to 20
#
interface GigabitEthernet1/0/0
port link-type hybrid
port hybrid tagged vlan 10 to 20
stp disable
loop-detection mode port-quitvlan
loop-detection recovery-time 30
#
interface GigabitEthernet2/0/0
port link-type hybrid
port hybrid tagged vlan 10 to 20
stp disable
loop-detection mode port-quitvlan
loop-detection recovery-time 30
#
snmp-agent trap enable feature-name LDTTRAP
#
return
验证
网络里出现环路后,执行 display loop-detection 看全局运行情况:
[Switch] display loop-detection
Loop Detection is enabled.
Detection interval time is 10 seconds.
Following VLANs enable loop-detection:
VLAN 10 to 20
Following ports are blocked for loop:
NULL
Following ports are shutdown for loop:
NULL
Following ports are nolearning for loop:
NULL
Following ports are trapped for loop:
NULL
Following ports are quitvlan for loop:
GigabitEthernet1/0/0 Include Vlans:
10 11 12 16 19
GigabitEthernet2/0/0 Include Vlans:
13 14 15 17 18
20
Quitvlan 名单里两个接口各退出了自己成环的那几个 VLAN,未列出的 VLAN 转发不受影响——这正是与整口关闭拉开差距的地方。再看单接口明细:
[Switch] display loop-detection interface gigabitethernet 1/0/0
The port is enabled.
The port's status list:
Status WorkMode Recovery-time EnabledVLAN
-----------------------------------------------------------------------
Quitvlan Quitvlan 30 10
Quitvlan Quitvlan 30 11
Quitvlan Quitvlan 30 12
Normal Quitvlan 30 13
Normal Quitvlan 30 14
Normal Quitvlan 30 15
Quitvlan Quitvlan 30 16
Normal Quitvlan 30 17
Normal Quitvlan 30 18
Quitvlan Quitvlan 30 19
Normal Quitvlan 30 20
哪个接口退出哪些 VLAN 是不定的,但最终接口会退出所有成环 VLAN。消除网络中的环路(如关闭问题接口、检查并修复设备间连线)后,等过恢复时间再查,接口各 VLAN 状态回到 Normal,业务全部复原。另外提醒一句,Loop Detection 检测要持续发送检测报文,耗费一定系统资源,不需要时记得及时关闭。
广播风暴一来全员救火,定位却常常要靠拔线试错。贵州诚鑫致达科技在维保项目里处理风暴告警,先看的往往就是环路检测日志里退出的 VLAN 清单,成环范围一目了然。你的网络若也是多 VLAN 共用上联,欢迎留言聊聊你们的防环做法。