BGP Path Attributes Part 1

In this lab I will demonstrate how BGP routes selection process works.

Objectives:

  • 7 Cisco IOU-L3 routers. For this lab scenario I have already configured all the routers.
  • 1 Cisco IOU-L2 Switch (optional: which is not really required for this lab scenario but is there for some other labs I am working on)
  • A route 24.7.3.56/32 from R7 will be advertised via BGP to R1 which it will learn through AS200 and AS500.
  • Check the default behavior of well-known mandatory and then manipulating the routes.
  • In this lab we will only modify configuration for the well-known mandatory and well-known discretionary path attributes.
    • Well-Known Mandatory (for example: Origin, AS Path, and Next Hop)
    • Well-Known Discretionary (for example: Local Preference)
BGP%20lab.png

BGP status and routes learned on R1.

R1#show ip bgp summary 
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 2, main routing table version 2
1 network entries using 140 bytes of memory
4 path entries using 320 bytes of memory
3/1 BGP path/bestpath attribute entries using 432 bytes of memory
3 BGP AS-PATH entries using 88 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 980 total bytes of memory
BGP activity 2/1 prefixes, 8/4 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.2.2.2         4          200       6       5        2    0    0 00:01:33        1
3.3.3.3         4          200       7       5        2    0    0 00:01:33        1
4.4.4.4         4          200       7       5        2    0    0 00:01:33        1
10.10.15.5      4          500       7       5        2    0    0 00:01:33        1

The show ip bgp summary is showing us that all BGP neighbors are in Established state and 1 prefix is being learned from each neighbor. 

Now lets check which route are we receiving. 

R1#show ip bgp         
BGP table version is 2, local router ID is 1.1.1.1
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
 *   24.7.3.65/32     2.2.2.2                                0 200 200 200 600 i
 *>                   3.3.3.3                                0 200 600 i
 *                    4.4.4.4                                0 200 600 i
 *                    10.10.15.5                             0 500 600 i

From the show ip bgp output we can see that we are receiving that single route 24.7.3.65/32 from all these neighbors but the valid and
best route chosen has a next hop of 3.3.3.3 (R3).

This is because the routes received from 2.2.2.2 is prepended 3 times so we see that it is not chosen as the best route due to the fact that
all other routes require going through 1 autonomous system to reach the destination IP whereas to reach through 2.2.2.2 it will require 3.

So why choose the route through 3.3.3.3?

Let's first look at the detailed output for this route from the show ip bgp 24.7.3.65/32, what we see is that this route is learned from 4 paths and all the BGP path attributes are matching except for the route learned through 2.2.2.2 which is AS-path prepended. For the rest of the routes we have a tie breaker for most of the path attributes.

R1#show ip bgp 24.7.3.65/32
BGP routing table entry for 24.7.3.56/32, version 2
Paths: (4 available, best #2, table default)
  Advertised to update-groups:
     2         
  Refresh Epoch 1
  200 200 200 600
    2.2.2.2 from 2.2.2.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 2
  200 600
    3.3.3.3 from 3.3.3.3 (3.3.3.3)
      Origin IGP, localpref 100, valid, external, best       <---Best path
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 2
  200 600
    4.4.4.4 from 4.4.4.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 2
  500 600
    10.10.15.5 from 10.10.15.5 (5.5.5.5)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0

So why route learned through 3.3.3.3 is chosen to be valid and best? it is because BGP selects this as the best path on comparing with all the other routes and
selected based on lower router-id.

If I remove the route-map on R2 which is prepending this route, let us see what happens. After removing the route-map I will clear the BGP peering and let the routes be learned again.

R1#show ip bgp 
BGP table version is 2, local router ID is 1.1.1.1
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
 *   24.7.3.65/32     3.3.3.3                                0 200 600 i
 *                    10.10.15.5                             0 500 600 i
 *>                   2.2.2.2                                0 200 600 i        
 *                    4.4.4.4                                0 200 600 i

As expected the route now chosen to be valid and best is from 2.2.2.2 because of having a lower router-id.
R1#show ip bgp 24.7.3.65/32                  
BGP routing table entry for 24.7.3.56/32, version 2
Paths: (4 available, best #3, table default)
  Advertised to update-groups:
     3         
  Refresh Epoch 2
  200 600
    3.3.3.3 from 3.3.3.3 (3.3.3.3)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 2
  500 600
    10.10.15.5 from 10.10.15.5 (5.5.5.5)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 2
  200 600
    2.2.2.2 from 2.2.2.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external, best
      rx pathid: 0, tx pathid: 0x0
  Refresh Epoch 2
  200 600
    4.4.4.4 from 4.4.4.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0

Now I will choose a path of my choice by configuring local-preference value of 200 for the route learned through 5.5.5.5 (R5).

R1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#route-map LOCAL_PREF permit 10
R1(config-route-map)#match ip address 1
R1(config-route-map)#set local-preference 200
R1(config-route-map)#exit
R1(config)#access-list 1 permit 24.7.3.65 log
R1(config)#router bgp 100
R1(config-router)#neighbor 10.10.15.5 route-map LOCAL_PREF in
R1(config-router)#exit
R1(config)#exit
R1#clear ip bgp *

R1#show ip bgp
BGP table version is 2, local router ID is 1.1.1.1
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
 *   24.7.3.65/32     2.2.2.2                                0 200 600 i
 *                    3.3.3.3                                0 200 600 i
 *                    4.4.4.4                                0 200 600 i
 *>                   10.10.15.5                    200      0 500 600 i

!- Now we see that the route learned from 10.10.15.5 will be chosen as valid and best because we have configured 
local-pref value of 200 which is higher then the default value of 100 for all other routes. 

R1#show ip bgp 24.7.3.65
BGP routing table entry for 24.7.3.56/32, version 2
Paths: (4 available, best #4, table default)
  Advertised to update-groups:
     4         
  Refresh Epoch 2
  200 600
    2.2.2.2 from 2.2.2.2 (2.2.2.2)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 2
  200 600
    3.3.3.3 from 3.3.3.3 (3.3.3.3)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 2
  200 600
    4.4.4.4 from 4.4.4.4 (4.4.4.4)
      Origin IGP, localpref 100, valid, external
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 3
  500 600
    10.10.15.5 from 10.10.15.5 (5.5.5.5)
      Origin IGP, localpref 200, valid, external, best     <---- Best route because of higher localpref of 200.
      rx pathid: 0, tx pathid: 0x0

I have covered AS-Path prepend, Local-preference and lowest Router-ID in this lab scenario. I will cover weight and MED in another lab.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License