Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


loops (BGP Address Family)


Hierarchy Level


For the specified BGP address family, allow the local device’s AS number in the received AS paths and specify the number of times the detection of the local device’s AS in the AS_PATH attribute is allowed. If the count exceeds the specified loop count, the system discards this route. For example, if you configure loops 1, the route is discarded if the neighbor’s local AS is detected in the path more than once. This prevents routing loops and is the default behavior. If you configure loops 2, the route is discarded if the neighbor’s local AS is detected more than 2 times.

For debugging, you can configure the keep all option If you want to hide this route.

Some examples of BGP address families are as follows:

  • inet unicast

  • inet-vpn multicast

  • inet6 any

  • l2vpn auto-discovery-only

  • ...

This list is truncated for brevity. For a complete list of protocol families for which you can specify the loops statement, enter the help apropos loops configuration command at the [edit protcols bgp] hierarchy level on your device.


The behavior of this statement is slightly different from the loops (Autonomous System) statement.


number—Maximum number of times that the local device’s AS number is allowed in the AS_PATH attribute to accept the route.

  • Range: 1 through 10

  • Default: None. The system does not take any action unless the loops (BGP Address Family) statement is configured.

Required Privilege Level

routing—To view this statement in the configuration.

routing-control—To add this statement to the configuration.

Release Information

Statement introduced in Junos OS Release 9.6.