BGP loop prevention

Written on by admin on. Posted in BGP

When BGP updates travel through different Autonomous Systems (AS), EBGP routers prepend their AS to AS PATH attribute.  BGP routers use this information to check through which Autonomous Systems certain updates passed. If a EBGP speaking router detects its own AS in AS PATH attribute update, the router will ignore the update and will not advertise it further to IBGP neighbors, because it is a routing information loop. This is a built in mechanism for loop prevention in BGP.

Let’s consider the following scenario:

BGP loop prevention

In the scenario above you see four BGP speaking routers. R1 and R2 are in AS (Autonomous System)  65001 and form IBGP neighbor relationship with each other. R3 is in AS 65002 and form EBGP neighborship with R1 and R4. R4 is in AS 65003 and form EBGP neighborship with R2 and R3. The only network prefix advertised in BGP is, which is advertised by R1. All the other routers learn this route from BGP. Router R2 learns this network prefix directly from R1 which is in the same AS.  Also, this prefix is sent to R3 by R1 as a BGP routing update and by R3 to R4. Router R4 in turn will send BGP routing update to R2. And now, routing information loop would have occurred if loop prevention mechanism wouldn’t exist.   Because routing update about received by R2 from R4 contains R2’s own AS (65001), R2 will reject that update and will not be sent further to other IBGP neighbors (in this case – R1).

To see BGP loop prevention in action, we’ll enable BGP debugging on R2 for updates received from R4, then will clear R4 ( from BGP neighbors. See it in output  below:

R2#debug ip bgp updates
BGP updates debugging is on for neighbor for address family: IPv4 Unicast
R2#clear ip bgp
*Mar  1 00:12:27.455: %BGP-5-ADJCHANGE: neighbor Down User reset
*Mar  1 00:12:28.679: %BGP-5-ADJCHANGE: neighbor Up
*Mar  1 00:12:28.683: BGP(0): send UPDATE (format), next, metric 0, path Local
*Mar  1 00:13:00.219: BGP(0): rcv UPDATE w/ attr: nexthop, origin i, originator, path 65003 65001, community , extended community
*Mar  1 00:13:00.223: BGP(0): rcv UPDATE about -- DENIED due to: AS-PATH contains our own AS;

As you can see (highlighted in red), there is an update sent by R4 to R2. That update was denied by R2 because it sees its own AS in AS-PATH.

This is how BGP handles BGP loop prevention of information updates between Autonomous Systems.  Well, that is just part of the story. To avoid routing information loops within the same AS, all IBGP routers must peer with every router within AS (only TCP sessions required, not physical connections) – this is called full mesh IBGP. IBGP uses split horizon rule (covered in other article), which states that routes learned from one IBGP neighbor is never sent to the rest of IBGP neighbors. That way, when you have full mesh IBGP, routing information loops will not occur, because all routers have the same routing information.


Trackback from your site.

Comments (2)

  • Steve


    Nice clearly written article.


  • Amjad


    Thanks for coming back after two years to write. eager to find more labs.


Leave a comment

six + 7 =