Configuration Guide
Ethernet Switch Configuration
Loopback Detection Configuration
16 min
introduction introduction loopback detection is a layer 2 network protection mechanism used to promptly detect and handle loops in the network network loops can cause broadcast, multicast, and unknown unicast packets to be sent repeatedly, resulting in waste of network resources or even network paralysis the loop detection function periodically sends detection packets through the interface and checks whether the packets return to the device, thereby determining whether there is a loop under the interface or vlan once a loop is detected, the device will send an alarm, record logs, and process the interface according to user configurations (such as shutting down the interface), putting the interface into a controlled state to minimize the impact of the loop on the network working principle working principle the implementation of loop detection is based on the following working mechanism on interfaces or vlans with loop detection enabled, the device sends detection packets at fixed time intervals (configured via loopback detection interval time) the detection packets are sent in broadcast mode, with the destination mac address being the broadcast address, the ethernet type being 0x9998, and the packet payload containing the sending port name or vlan information loop detection supports two detection granularities interface based detection after enabling loop detection in the interface view, the device only sends detection packets from the interface itself and monitors whether it receives the packets it sent from the same interface if received, it is determined that there is a loop in the network connected to this interface, and the configured action for the interface is triggered vlan based detection after enabling loop detection in the vlan view, the device sends detection packets on all member interfaces within the vlan and monitors whether any interface in the vlan receives the packets it sent as long as the packet is received by any interface in the vlan (which can be a different port from the sending interface), it is determined that there is a loop in the vlan, and the configured action for the interfaces in the vlan is triggered after detecting a loop, the device immediately executes the configured processing action by default, shutting down the interface (shutdown) or only recording a log (logging) after the interface is shut down, the device continuously monitors the loop status if an automatic recovery time is configured (loopback detection recovery time), the device will attempt to recover the interface after this time; if the loop has been eliminated, the interface returns to its normal state; otherwise, it remains in a controlled state users can also manually recover the shut down interface (via no shutdown or clear loopback detection) configuration configuration operation description configure the sending cycle of detection messages optional (global) configure the sending cycle of alarm logs optional (global) enable the loop detection function of the interface/vlan mandatory (interface/vlan) configure loop detection processing actions optional (interface) configure the automatic recovery time of the interface optional (interface) configure the sending cycle of detection messages configure the sending cycle of detection messages use this command to set the sending interval of loop detection packets the smaller the interval, the higher the detection sensitivity, but the greater the system resource consumption operation command description enter the system configuration view configure terminal configure the sending cycle loopback detection interval time interval interval the value range is 10 to 300 seconds, with a default of 30 seconds configure the sending cycle of alarm logs configure the sending cycle of alarm logs this command sets the interval at which the system repeatedly prints alarm logs after an interface is shut down due to a loop the default value of 0 means that repeated printing is not performed operation command description enter the system configuration view configure terminal configure the log sending cycle loopback detection log time interval interval the value range is 10–300 seconds, with a default of 0 seconds enable the loop detection function of the interface/vlan enable the loop detection function of the interface/vlan when configured in the interface view, it only takes effect on the current interface and adopts an interface based detection mechanism; when configured in the vlan configuration view, it takes effect on all ports within the vlan and adopts a vlan based detection mechanism operation command description enter the interface configuration view interface ethernet interface id enable interface loop detection loopback detection enable or enter the vlan configuration view vlan vlan id enable vlan loop detection loopback detection enable configure loop detection processing actions configure loop detection processing actions the action that the device performs on the interface when a loop is detected operation command description enter the interface configuration view interface ethernet interface id configure action loopback detection action {logging | shutdown} logging only record logs; shutdown record logs and close the interface (default) configure the automatic recovery time of the interface configure the automatic recovery time of the interface after the interface is shut down due to a loop, how long will it take to automatically attempt to return to the normal state? if the loop has disappeared after recovery, the interface will be re enabled operation command description enter the interface configuration view interface ethernet interface id configuration recovery time loopback detection recovery time interval interval the value range is 10 to 65535 seconds note if the automatic interface recovery time is not configured, the interface will not recover automatically after being shut down you need to manually recover it by executing the commands "shutdown" and "no shutdown" in sequence under the interface view alternatively, you can restart all shutdown interfaces by executing the "clear loopback detection" command under the system view display and maintenance display and maintenance operation command check the global, port/vlan configurations for loop detection show loopback detection config check the loop detection status (interfaces that are shut down and the reasons) show loopback detection status check the errdown status of all interfaces show interface errdown clear the loop detection information and re enable all interfaces that have been shut down clear loopback detection configuration example configuration example networking requirements there are multiple user vlans under a certain switch to prevent loops caused by users' incorrect connections within vlan 100, it is required to enable vlan based loop detection in vlan 100 when a loop is detected, the port should be shut down, and the interface automatic recovery time should be set to 60 seconds meanwhile, configure interface based loop detection for the individual port ethernet47, with the action being only logging without shutting down the port the global loop detection period is 10 seconds, and the interval for sending alarm logs is 10 seconds configuration steps 1\ configure the global loop detection period sonic(config)# loopback detection interval time 10 sonic(config)# loopback detection log time 10 2\ enable loop detection in the vlan view, add the interface to the vlan in the interface view, and configure the loop detection action and the automatic recovery time of the interface sonic(config)# vlan 100 sonic(config vlan 100)# loopback detection enable sonic(config vlan 100)# exit sonic(config)# interface ethernet 1 sonic(config if 1)# switchport access vlan 100 sonic(config if 1)# loopback detection action shutdown sonic(config if 1)# loopback detection recovery time 60 sonic(config)# interface ethernet 2 sonic(config if 2)# switchport access vlan 100 sonic(config if 2)# loopback detection action shutdown sonic(config if 2)# loopback detection recovery time 60 sonic(config)# interface ethernet 3 sonic(config if 3)# switchport access vlan 100 sonic(config if 3)# loopback detection action shutdown sonic(config if 3)# loopback detection recovery time 60 3\ enable the ethernet47 loop detection function and configure the loop detection action sonic(config)# interface ethernet 47 sonic(config if 47)# loopback detection enable sonic(config if 47)# loopback detection action logging 4\ verification view configuration information sonic# show loopback detection config packets interval time 10 (sec) log interval time 10 (sec) port/vlan action recovery time status \ ethernet1 shutdown 60 ethernet2 shutdown 60 ethernet3 shutdown 60 ethernet47 logging enable vlan100 enable check the loop detection status (if vlan100 has a loop) sonic# show loopback detection status you can re up err down ports one by one by "no shutdown" under interface config, re up all by "clear loopback detection", or configure "loopback detection recovery time" for automatic recovery loopback is detected port status caused by time \ ethernet1 shutdown vlan100 00 00 05 ethernet2 shutdown vlan100 00 00 05 ethernet3 shutdown vlan100 00 00 05 note the command "show loopback detection status" only displays real time loop detection events when an interface is shut down due to a loop and the loop disappears for a period of time (3 times the interval), the command will no longer display relevant information in this case, if you need to check the interfaces that have been shut down by loop detection, please use the "show interface errdown" command "time" indicates the time elapsed since the last detected loop
