Network Requirements
- Device1 and Device2 form a loop through two links, and all L2 Ethernet interfaces in the loop is in one VLAN.
- On Device1, loopback detection has been enabled.
- After Device1 detects a loop, it closes the interconnected L2 Ethernet interfaces to eliminate the loop.
Network Topology
![Networking for Configuring the Local Loopback Detection Function](/storage/images/Document/Maipu/ethernet-switching/networking-for-config-local-loopback.jpg)
Figure 10-2 Networking for Configuring the Local Loopback Detection Function
Configuration Steps
Step 1: Configure VLANs, and configure the link type of the L2 Ethernet interface.
#On Device1, create VLAN2.
Device1#configure terminal
Device1(config)#vlan 2
Device1(config-vlan2)#exit
|
#On Device1, configure the link type of L2 Ethernet interface gigabitethernet0/1 and gigabitethernet0/2 to Trunk and allow the services of VLAN2 to pass.
Device1(config)# interface gigabitethernet 0/1-0/2
Device1(config-if-range)#switchport mode trunk
Device1(config-if-range)#switchport trunk allowed vlan add 2
Device1(config-if-range)#exit
|
#On Device2, create VLAN2.
Device2#configure terminal
Device2(config)#vlan 2
Device2(config-vlan2)#exit
|
#Configure the link type of L2 Ethernet interface gigabitethernet0/1 and gigabitethernet0/2 to Trunk, allow the services of VLAN2 to pass, and close the spanning tree.
Device2(config)# interface gigabitethernet 0/1-0/2
Device2(config-if-range)#switchport mode trunk
Device2(config-if-range)#no switchport trunk allowed vlan 1
Device2(config-if-range)#switchport trunk allowed vlan add 2
Device2(config-if-range)#no spanning-tree enable
Device2(config-if-range)#exit
|
Step 2: Enable the loopback detection function.
#On Device1, enable the loopback detection function globally.
Device1(config)#loopback-detection enable
|
#On Device1, query the loopback detection status.
Device1#show loopback-detection
------------------------------------------------------
Global loopback-detection : ENABLE
------------------------------------------------------
Interface Loopback Time(s) State Control
------------------------------------------------------
gi0/1 DISABLE 30 NORMAL TRUE
gi0/2 DISABLE 30 NORMAL TRUE
#The L2 Ethernet interface gigabitethernet0/1 on Device1 enables the loopback detection function.
Device1(config)#interface gigabitethernet 0/1
Device1(config-if-gigabitethernet0/1)#loopback-detection enable
Device1(config-if-gigabitethernet0/1)#exit
|
Step 3: Check the result.
#On Device1, query the loopback detection status.
After a loop is detected:
Device1#show loopback-detection
--------------------------------------------------------
Global loopback-detection : ENABLE
--------------------------------------------------------
Interface Loopback Time(s) State Control
--------------------------------------------------------
gi0/1 ENABLE 30 ERR-DISABLE TRUE
gi0/2 DISABLE 30 NORMAL TRUE
#A loop has been detected on Device1. The L2 Ethernet interface gigabitethernet0/1 is closed, and the device outputs the following prompt information:
Jul 30 2014 03:29:59: %LOOP-BACK-DETECTED : loop-back send tag packet in vlan2 on gigabitethernet0/1, detected in vlan2 from gigabitethernet0/2
Jul 30 2014 03:29:59: %LINK-INTERFACE_DOWN-4: interface gigabitethernet0/1, changed state to down
Jul 30 2014 03:29:59: %LINEPROTO-5-UPDOWN : gigabitethernet0/1 link-status changed to err- disable
|
#On Device1, query the status of L2 Ethernet interface gigabitethernet0/1, and you will find that the link status of the L2 Ethernet interface gigabitethernet0/1 is changed to Down.
Device1#show interface gigabitethernet 0/1
gigabitethernet0/1 configuration information
Description :
Status : Enabled
Link : Down (Err-disabled)
Set Speed : Auto
Act Speed : Unknown
Set Duplex : Auto
Act Duplex : Unknown
Set Flow Control : Off
Act Flow Control : Off
Mdix : Auto
Mtu : 1824
Port mode : LAN
Port ability : 10M HD,10M FD,100M HD,100M FD,1000M FD
Link Delay : No Delay
Storm Control : Unicast Disabled
Storm Control : Broadcast Disabled
Storm Control : Multicast Disabled
Storm Action : None
Port Type : Nni
Pvid : 1
Set Medium : Copper
Act Medium : Copper
Mac Address : 0000.0000.008b
![note](/storage/images/Document/Maipu/note-icon.jpg)
-
When gigabitethernet 0/1 or gigabitethernet 0/2 of Device1 is L3 Ethernet interface, there is no loop in the networking environment.