Enabling loopback detection on an Ethernet interface

If a device receives a packet that it sent, a loop has occurred to the device. Loops might cause broadcast storms, which degrade network performance. You can use this feature to detect whether a loop has occurred.

Depending on whether the receiving interface is the same as the sending interface, loops include the following types:

Figure 3: Single-port loopback

Figure 4: Multi-port loopback

You can enable loopback detection to detect loops on an interface and, if the interface supports the loopback-detection action command, configure the protective action to take on the receiving interface when a loop is detected, for example, to shut down the interface. Depending on whether a protective action is configured, the device takes the actions in Table 3 to alleviate the impact of the loop condition.

Table 3: Actions to take upon detection of a loop condition

Port type

Actions

No protective action is configured

A protective action is configured

Access port

  • Place the receiving interface in controlled mode. The interface discards all incoming packets, but still forwards outgoing packets.

  • Generate traps and log messages.

  • Delete all MAC address entries of the interface.

  • Perform the configured protective action.

  • Generate traps and log messages.

  • Delete all MAC address entries of the interface.

Hybrid or trunk port

  • Generate traps and log messages.

  • If loopback detection control is enabled, place the receiving interface in controlled mode. The interface discards all incoming packets, but still forwards outgoing packets.

  • Delete all MAC address entries of the interface.

  • Generate traps and log messages.

  • If loopback detection control is enabled, take the configured protective action on the interface.

  • Delete all MAC address entries of the interface.

Configuration restrictions and guidelines

Configuration procedure

To configure loopback detection:

Step

Command

Remarks

1. Enter system view.

system-view

N/A

2. Enable global loopback detection.

loopback-detection enable

By default, global loopback detection is disabled.

3. Enable multi-port loopback detection.

loopback-detection multi-port-mode enable

Optional.

By default, multi-port loopback detection is disabled, and the device can only detect single-port loopback.

4. Set the loopback detection interval.

loopback-detection interval-time time

Optional.

The default setting is 30 seconds.

5. Enter Ethernet interface view or port group view.

  • Enter Ethernet interface view:interface interface-type interface-number

  • Enter port group view:port-group manual port-group-name

Use one of the commands.

To configure loopback detection on one interface, enter Ethernet interface view.

To configure loopback detection on a group of Ethernet interfaces, enter port group view.

6. Enable loopback detection on the interface.

loopback-detection enable

By default, loopback detection is disabled.

7. Enable loopback detection control on a trunk port or a hybrid port.

loopback-detection control enable

Optional.

By default, loopback detection control is disabled.

8. Enable loopback detection in all the VLANs on the trunk or hybrid port.

loopback-detection per-vlan enable

Optional.

By default, a trunk or hybrid port performs loopback detection only in its PVID.

9. Set the protective action to take on the interface when a loop is detected.

loopback-detection action { no-learning | semi-block | shutdown }

Optional.

By default, when a loop is detected on an interface, the interface does not receive or send packets, and the system generates traps and log messages and deletes all MAC address entries of the interface.