Thursday, April 16, 2015

Configuring Cisco - BGP Best External

In this blogtorial, we will briefly explore "BGP Best External" feature and walk through a scenario on how we can achieve sub-millisecond convergence with BGP. This feature is usually used in MPLS environment, although you can pretty much use it anywhere if the design allows it. Here is a simple topology so follow me.


In this topology we have 2 CE routers eBGP peered with 2 PE routers (R2 and R3). CE-1 is primary for 192.168.1.0/24 and CE-2 is backup for 192.168.1.0/24. The 2 PE routers (R2 and R3) are iBGP peered with themselves and R1 so we have a full mesh iBGP here.

Now if we look at the BGP table for R1.

 R1#sh ip bgp   
    Network        Next Hop      Metric LocPrf Weight Path  
  *>i 21.21.21.0/24  12.12.12.2        0    100   0       i  
  *>i 32.32.32.0/24  13.13.13.3        0    100   0       i  
  *>i 192.168.1.0    21.21.21.1        0    100   0    12 i  

We can clearly see that R1 only has one path to 192.168.1.0/24 and that is via R2. This is because R2 gets the route and sends to R3 and R1 and since iBGP learned route can't be advertised to other iBGP peers R3 does not advertise it to R1. Now let's create a failure on CE-1 by shutting down the eBGP peer to R2 and see what happens on R1.

 R1# debug ip routing  
 *Apr 16 08:15:38.742: RT: del 192.168.1.0 via 21.21.21.1, bgp metric [200/0]  
 *Apr 16 08:15:38.742: RT: delete network route to 192.168.1.0/24  
 *Apr 16 08:15:38.745: RT: updating bgp 192.168.1.0/24 (0x0) : via 32.32.32.2  0 1048577  
 *Apr 16 08:15:38.745: RT: add 192.168.1.0/24 via 32.32.32.2, bgp metric [200/0]  

 R1#sh ip bgp   
    Network        Next Hop      Metric LocPrf Weight Path  
  *>i 21.21.21.0/24  12.12.12.2        0  100     0     i  
  *>i 32.32.32.0/24  13.13.13.3        0  100     0     i  
  * i 192.168.1.0    32.32.32.2        0  100     0    12 12 12 12 i  

So far this is pretty elementary, we have the route from R2 being withdrawn on R3 and R1 due to a BGP withdraw message from R2.


At this point R1, PE2, and PE3 do not have a route to 192.168.1.0/24.

R3 now goes through the "BGP Best Path Selection" and figures out that it has another route from CE-2 for the same prefix 192.168.1.0/24 which can now be put into the routing table. R3 then starts to advertise this route to R1 and R2 via iBGP. At this point R1 and R2 does have a route to 192.168.1.0/24 via R3.

You can see from the debug ip routing on R1 that 192.168.1.0 is deleted and is updated with the newly received information from R3. One key thing to note here is the convergence time. It took about 3 milliseconds for BGP withdraws, Best path selection and finally for the route to be installed in the RIB.

Now let's see what happens after we configure "BGP Best External" which basically states advertise the BEST route to your peers but also advertise all other eBGP learned paths as well. Let's see how this affects the BGP convergence time.

 R2# sh run | sec bgp   
 router bgp 123  
   bgp advertise-best-external  

 R3# sh run | sec bgp   
 router bgp 123  
  bgp advertise-best-external  

Once we configure the "bgp advertise-best-external" under the global BGP process, we can see below that R3 now has a "b" and a "x" next to the 192.168.1.0/24 received from CE-2. b for backup-path and x for best-external. 
 R3#sh ip bgp   
 BGP table version is 53, local router ID is 150.1.3.3  
 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,   
        r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,   
        x best-external, a additional-path, c RIB-compressed,   
 Origin codes: i - IGP, e - EGP, ? - incomplete  
 RPKI validation codes: V valid, I invalid, N Not found  
    Network     Next Hop      Metric LocPrf Weight Path  
  *>i 21.21.21.0/24  23.23.23.2        0  100   0 i  
  *> 32.32.32.0/24  0.0.0.0         0     32768 i  
  *>i 192.168.1.0   21.21.21.1        0  100   0 12 i  
  *b x         32.32.32.2        0       0 12 12 12 12 i  

And as you can see R3 is now advertising a eBGP path even though this eBGP is not in the routing table to R1 and as such R1 now has two exit points for 192.168.1.0/24.

 R3#sh ip bgp nei 13.13.13.1 advertised-routes   
    Network     Next Hop      Metric LocPrf Weight Path  
  *> 32.32.32.0/24  0.0.0.0         0     32768 i  
  *b x192.168.1.0   32.32.32.2        0       0 12 12 12 12 i  

R1, after running through the "BGP best path selection" is picking the path via R2 because R2 has the shorter AS PATH length.

 R1#sh ip bgp   
     Network     Next Hop      Metric LocPrf Weight Path  
  *>i 21.21.21.0/24  12.12.12.2        0  100   0     i  
  *>i 32.32.32.0/24  13.13.13.3        0  100   0     i  
  *>i 192.168.1.0    21.21.21.1        0  100   0     12 i  
  * i                32.32.32.2        0  100   0     12 12 12 12 i  

Now let's create the same failure on CE-1 by shutting down the eBGP peer to R2 and see what happens on R1 and how fast it converges.

 CE-1# conf t  
 CE-1(config)#router bgp 12  
 CE-1(config-router)#nei 21.21.21.2 shut  

R1 receives the BGP withdraw message from R2 since R2 no longer has the best route and as soon as R1 receives the withdraw message the backup route from R1's BGP table is put into the RIB.

 R1# debug ip routing  
 *Apr 16 08:18:54.554: BGP(0): 12.12.12.2 rcv UPDATE about 192.168.1.0/24 -- withdrawn
 *Apr 16 08:18:54.555: RT: updating bgp 192.168.1.0/24 (0x0) : via 32.32.32.2  0 1048577  
 *Apr 16 08:18:54.555: RT: closer admin distance for 192.168.1.0, flushing 1 routes  
 *Apr 16 08:18:54.555: RT: add 192.168.1.0/24 via 32.32.32.2, bgp metric [200/0]  

Notice the convergence time above ~ 1ms compared to ~ 3ms before we enabled "BGP Best External".

"BGP Best External" in a nice feature that can improve BGP convergence time and if you are interested in reading more about this feature here are some good white papers.

BGP Best External - Cisco Guide
BGP IETF Draft 05

There is actually one more way you can advertise non-best-paths and that is via "BGP additional paths".

BGP Additional Paths

Many more articles to come so ....

Please subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.

"Success is the biggest enemy of success. Always try to better your best..."

No comments:

Post a Comment