交换机通过Loopback Detection检测(设备所在网络环路)

组网图形

    

 Loopback Detection简介

见上篇文章(详情见),不再赘述。

组网需求

  • 如图1所示,某小型企业采用二层组网,所属VLAN为100。由于人员流动性大,网络拓扑变动频繁,变动往往会因连接错误或配置错误而产生环路,进而导致广播风暴,影响Switch以及整个网络的通信。
  • 用户希望能在Switch上检测到网络中的环路,并希望环路存在时阻塞接口以减小环路对Switch及其所在网络的冲击,环路消失时阻塞接口能自动恢复到正常状态。

配置思路

  • 为检测Switch所在网络是否存在环路,可以在Switch上的GE1/0/1和GE1/0/2上分别配置Loopback Detection功能;同时本例中,Switch发出的Untagged检测报文会被网络中的其他交换机丢弃,导致检测报文无法送回Switch,进而无法实现环路检测,所以本例必须配置对指定VLAN进行环路检测。配置思路如下:
  1. 使能接口的Loopback Detection功能,并配置对VLAN 100进行环路检测,实现对Switch所在网络的环路检测。
  2. 配置Loopback Detection处理动作和接口自动恢复时间,实现发现环路后,Switch自动阻塞接口以减少环路对其及其所在网络的冲击,环路消失后接口自动恢复。

操作步骤

  • 1.使能接口的Loopback Detection功能
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch]  interface gigabitethernet 1/0/1
[Switch-GigabitEthernet1/0/1] loopback-detect enable   //使能接口的Loopback Detection功能
[Switch-GigabitEthernet1/0/1] quit
[Switch]  interface gigabitethernet 1/0/2
[Switch-GigabitEthernet1/0/2] loopback-detect enable   //使能接口的Loopback Detection功能
[Switch-GigabitEthernet1/0/2] quit
  •  2.配置接口对指定VLAN报文进行环路检测
[Switch] vlan 100
[Switch-vlan100] quit
[Switch]  interface gigabitethernet 1/0/1
[Switch-GigabitEthernet1/0/1] port link-type hybrid   //V200R005C00及以后版本交换机接口的缺省链路类型不是Hybrid类型,用户可根据需要执行命令port link-type hybrid配置接口的链路类型为Hybrid
[Switch-GigabitEthernet1/0/1] port hybrid tagged vlan 100
[Switch-GigabitEthernet1/0/1] loopback-detect packet vlan 100   //配置接口对VLAN100进行环路检测
[Switch-GigabitEthernet1/0/1] quit
[Switch]  interface gigabitethernet 1/0/2
[Switch-GigabitEthernet1/0/2] port link-type hybrid  
[Switch-GigabitEthernet1/0/2] port hybrid tagged vlan 100
[Switch-GigabitEthernet1/0/2] loopback-detect packet vlan 100   //配置接口对VLAN100进行环路检测
[Switch-GigabitEthernet1/0/2] quit
  •  3.配置Loopback Detection处理动作和环路消失后接口的自动恢复时间
[Switch]  interface gigabitethernet 1/0/1
[Switch-GigabitEthernet1/0/1] loopback-detect action block   //配置Loopback Detection检测到环路后对接口的处理动作为Block
[Switch-GigabitEthernet1/0/1] loopback-detect recovery-time 30   //配置环回消失后接口的恢复时间为30秒
[Switch-GigabitEthernet1/0/1] quit
[Switch]  interface gigabitethernet 1/0/2
[Switch-GigabitEthernet1/0/2] loopback-detect action block   //配置Loopback Detection检测到环路后对接口的处理动作为Block
[Switch-GigabitEthernet1/0/2] loopback-detect recovery-time 30   //配置环回消失后接口的恢复时间为30秒
[Switch-GigabitEthernet1/0/2] quit
  •  4.验证配置结果

  a.执行命令display loopback-detect检查配置是否成功。

[Switch] display loopback-detect 
Loopback-detect sending-packet interval:  5                                                                                         
                                                                                                                                   
----------------------------------------------------------------------------------                                                  
Interface                     RecoverTime  Action     Status                                                                        
----------------------------------------------------------------------------------                                                  
GigabitEthernet1/0/1          30           block      NORMAL                                                                        
GigabitEthernet1/0/2          30           block      NORMAL 
----------------------------------------------------------------------------------

   上述显示信息表明配置成功。

  b.配置成功后,等待一段时间(约5秒),执行命令display loopback-detect检查接口GE1/0/1或GE1/0/2是否有一个被阻塞。

[Switch] display loopback-detect 
Loopback-detect sending-packet interval:  5                                                                                         
                                                                                                                                   
----------------------------------------------------------------------------------                                                  
Interface                     RecoverTime  Action     Status                                                                        
----------------------------------------------------------------------------------                                                  
GigabitEthernet1/0/1          30           block      NORMAL                                                                        
GigabitEthernet1/0/2          30           block      BLOCK(Loopback detected) 
----------------------------------------------------------------------------------

   上述显示信息表明,接口GE1/0/2被阻塞了。

  c.关闭接口GE1/0/1,30秒后,执行命令display loopback-detect检查接口GE1/0/2是否恢复为正常状态。

[Switch] display loopback-detect 
Loopback-detect sending-packet interval:  5                                                                                         
                                                                                                                                   
----------------------------------------------------------------------------------                                                  
Interface                     RecoverTime  Action     Status                                                                        
----------------------------------------------------------------------------------                                                  
GigabitEthernet1/0/1          30           block      NORMAL                                                                        
GigabitEthernet1/0/2          30           block      NORMAL 
----------------------------------------------------------------------------------

   上述显示信息表明,接口GE1/0/2恢复为正常状态。

 

posted @ 2020-11-25 09:07  讲文张字  阅读(3896)  评论(0编辑  收藏  举报
返回顶部