BGP_Path_Selection_Top

^ I created this mid-session, but put it here as well as I like to illustrate the struggle at the beginning of the post 🙂

There are 3 well-known and mandatory attributes a BGP Speaker includes in updates to other BGP Speakers, that they must know how to speak (or they aren’t speaking BGP) which include “origin”, “AS_PATH”, and “Next-Hop”.

Here is an explanation of the first two before we get into configuring Best-Path’s:

Origin

This attribute can be found with the command “sh ip bgp at the very far right hand side:

R5#sh ip bgp
BGP table version is 3, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
              r RIB-failure, S Stale
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       172.12.15.1               0                       0           100    i
*> 5.5.5.5/32       0.0.0.0                        0                                   32768 i

I’ve highlighted in red the Origin, not to be confused with the Status codes above them, which is all the way to the left!

By reviewing the code table it shows it is IGP, meaning it is a route that originated from an IGP (Interior Gateway Protocol) network via the network command, whereas “e” for indicates a Path originating from an EGP (External Gateway Protocol). Now the ? (incomplete) in Origin codes means the true origin of the route is unclear as it was learned via Redistribution.

In Beth Past selection, the order goes: i > e > ?, with lots more explanation while discussing the Well-Known mandatory attribute:

AS_PATH

The AS Path shows the Autonomous System, as seen in the above out for “sh ip BGP” output:

R5#sh ip bgp
BGP table version is 3, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
              r RIB-failure, S Stale
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       172.12.15.1               0                            0       100 i
*> 5.5.5.5/32       0.0.0.0                        0                                   32768 i

The AS_PATH attribute shows the AS’s that are along the Path to the destination network (illustrated at end of post), including the AS the destination network resides in. In the illustration above we only have the destination network remote path, we will see if we can remedy that soon by getting the NBMA / R4 into the mix soon…

With BGP the shorter the path is, the better the path is during best-path selection process.

So the AS_PATH’s main purpose is really to prevent BGP routing loops, as should a BGP Speaker receive an its own AS # in the path to a destination, the route is discarded.

Next-Hop

This attribute is a tricky subject, and will be covered in my next post, and that is all the time I will spend on Next-Hop for now.

Those are the three attributes as far as I will explain them for now, onto more complex things!

I now see I am going to need a new Topology to simulate Path selection, I will BRB.

… creating new MS Paint Topology in paint and re-wiring lab, please hold.

BGP_Path_Selection_Top

BAM! Now given this NBMA has given me some grief with other protocols and it has to pass through that switch, which I have no idea what configs it needs (if it needs any at all), however I did put on “ip routing” on it for good measure.

So just to verify I got everything correctly, I am going to start with R1 and work our way to R5 with a “sh ip bgp summ” to see if everything is running smooth so far:

R1

R1#sh ip bgp summ
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 3, main routing table version 3
2 network entries using 258 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 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 758 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.12.15.5     4   500     117     106        3    0    0 01:41:56        1
172.12.123.2    4   200       7       7        3    0    0 00:01:20        0
172.12.123.3    4   100       5       7        3    0    0 00:01:47        0
R1#

R2
R2#sh ip bgp summ
BGP router identifier 2.2.2.2, local AS number 200
BGP table version is 4, main routing table version 4
2 network entries using 258 bytes of memory
3 path entries using 156 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
3 BGP AS-PATH entries using 72 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 982 total bytes of memory
BGP activity 2/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.12.23.4     4   400      34      33        4    0    0 00:27:43        1
172.12.123.1    4   100       7       7        4    0    0 00:01:37        2
R2#

R3
R3#sh ip bgp summ
BGP router identifier 3.3.3.3, local AS number 100
BGP table version is 2, main routing table version 2
2 network entries using 258 bytes of memory
2 path entries using 104 bytes of memory
3/1 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 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 758 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.12.23.4     4   400      33      31        2    0    0 00:26:55        0
172.12.123.1    4   100       8       6        2    0    0 00:02:18        2
R3#

R4

R4#sh ip bgp summ
BGP router identifier 4.4.4.4, local AS number 400
BGP table version is 3, main routing table version 3
2 network entries using 272 bytes of memory
3 path entries using 168 bytes of memory
3/2 BGP path/bestpath attribute entries using 384 bytes of memory
3 BGP AS-PATH entries using 72 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 896 total bytes of memory
BGP activity 2/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.12.23.2     4          200      34      35        3    0    0 00:28:26        2
172.12.23.3     4          100      32      34        3    0    0 00:27:24        1
R4#

R5
R5#sh ip bgp summ
BGP router identifier 5.5.5.5, local AS number 500
BGP table version is 3, main routing table version 3
2 network entries using 240 bytes of memory
2 path entries using 104 bytes of memory
2/2 BGP path/bestpath attribute entries using 248 bytes of memory
1 BGP AS-PATH entries using 24 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 616 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.12.15.1     4          100     108     118        3    0    0 01:43:30        1
R5#

So we are all neighbors now, using just simply the neighbor command to as noted above in the Topology, and since then I have done “network x.x.x.x mask 255.255.255.255” for all routers loopback addresses as well (though I’m not sure if / how they’ll propagate).

When you are getting tired, it is hard to make that excellent of an illustration in paint of a BGP Topology and stay on track, but when I saw this output it made it all worth it:

R4#sh ip bgp
BGP table version is 6, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32       172.12.23.2                            0 200 100 i
*>                         172.12.23.3                            0 100 i
*  2.2.2.2/32        172.12.23.3                            0 100 200 i
*>                         172.12.23.2              0             0 200 i
*  3.3.3.3/32        172.12.23.2                            0 200 100 i
*>                         172.12.23.3              0             0 100 i
*> 4.4.4.4/32           0.0.0.0                  0         32768 i
*> 5.5.5.5/32       172.12.23.2                            0 200 100 500 i
R4#

Queue the angels to sing! In fact, before I have some kind of freak power outage, I am going to run through and “wr” all routers and backup their configs. It might not seem like a lot, but coming this far and learning a completely new heavy duty subject puts an extra load on the study sessions – But we shall carry on.

Now I pre-configured static routes all over the place when the lab began thinking I was going to need them, but I am going to “no ip route …” all of them, and see what we get on R4. I’ll spare the output, but after removing all static routes in the entire network:

R4#sh ip bgp
BGP table version is 6, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32       172.12.23.2                            0 200 100 i
*>                        172.12.23.3                            0 100 i
*  2.2.2.2/32       172.12.23.3                            0 100 200 i
*>                        172.12.23.2              0             0 200 i
*  3.3.3.3/32       172.12.23.2                            0 200 100 i
*>                        172.12.23.3              0             0 100 i
*> 4.4.4.4/32       0.0.0.0                  0         32768 i
*> 5.5.5.5/32       172.12.23.2                            0 200 100 500 i
R4#sh ip bgp summ
BGP router identifier 4.4.4.4, local AS number 400
BGP table version is 6, main routing table version 6
5 network entries using 680 bytes of memory
8 path entries using 448 bytes of memory
7/5 BGP path/bestpath attribute entries using 896 bytes of memory
5 BGP AS-PATH entries using 120 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 2144 total bytes of memory
BGP activity 5/0 prefixes, 8/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.12.23.2     4          200      70      72        6    0    0 01:00:29        4
172.12.23.3     4          100      66      71        6    0    0 00:59:27        3

R4#sh ip route

Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1 subnets

B        1.1.1.1 [20/0] via 172.12.23.3, 00:35:06

      2.0.0.0/32 is subnetted, 1 subnets

B        2.2.2.2 [20/0] via 172.12.23.2, 00:25:12

      3.0.0.0/32 is subnetted, 1 subnets

B        3.3.3.3 [20/0] via 172.12.23.3, 00:25:42

      4.0.0.0/32 is subnetted, 1 subnets

C        4.4.4.4 is directly connected, Loopback4

      5.0.0.0/32 is subnetted, 1 subnets

B        5.5.5.5 [20/0] via 172.12.23.2, 00:34:35

      172.12.0.0/16 is variably subnetted, 2 subnets, 2 masks

C        172.12.23.0/24 is directly connected, FastEthernet0/1

L        172.12.23.4/32 is directly connected, FastEthernet0/1

R4#

Note all routes are AD 20, because to this Router has no iBGP Peers, so these are all eBGP network advertisements, NOT routes. Now the thing about ping is not a valid test of Peering reachability:

R4#ping 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
R4#

That was no joke, because they are EGP network advertisements, not dynamic routes like with IGP’s.

Now to demonstrate the difference with iBGP vs eBGP AD’s, lets take a look at R1’s “sh ip route” :

R1#sh ip route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback1
     2.0.0.0/32 is subnetted, 1 subnets
B       2.2.2.2 [20/0] via 172.12.123.2, 00:35:08
     3.0.0.0/32 is subnetted, 1 subnets
B       3.3.3.3 [200/0] via 172.12.123.3, 00:35:48

     4.0.0.0/32 is subnetted, 1 subnets
B       4.4.4.4 [20/0] via 172.12.123.2, 00:15:56
     5.0.0.0/32 is subnetted, 1 subnets
B       5.5.5.5 [20/0] via 172.12.15.5, 02:25:11
     172.12.0.0/24 is subnetted, 2 subnets
C       172.12.15.0 is directly connected, FastEthernet0/1
C       172.12.123.0 is directly connected, Serial0/0
R1#

Looks like R1 has an iBGP peer, by it’s default AD of 200, and all others again are the default AD for eBGP of 20.

Now from R1, I want to go over the new output we are looking at from above output dumps that have made no sense until this very moment:

R1# sh ip bgp
BGP table version is 8, 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
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.1/32       0.0.0.0                                                  0   32768 i
*> 2.2.2.2/32       172.12.123.2             0                        0      200 i
*>i3.3.3.3/32       172.12.123.3             0          100       0 i
* i4.4.4.4/32       172.12.23.4                0           100      0       400 i

*>                         172.12.123.2             0            200              400 i

*> 5.5.5.5/32       172.12.15.5              0             0                   500 i
R1#

To start off with the oddity highlighed in red, you see a valid path, then a best valid path that doesn’t have a loopack number in front of it. If you see this, it means it has multiple paths to the same loopback, but the best valid path is denoted as such without the loopback in front of it.

***When looking at the “sh ip bgp” table, do not let your eyes see the first entry for a destination and go with that as the best path, really pay attention to look over all paths beneath it to see if a different path is marked as best/valid***

Now there is a long winded list of what makes up the best path from most preferred attribute to least:

  1. Highest weight preferred (BGP Weight is a Cisco proprietary attribute)
  2. If tie or non-Cisco routers involved, highest local preference is preferred (LocPrf in “sh ip bgp”)
  3. Locally originated path preferred
  4. Shortest AS_PATH preferred
  5. Best Origin Code ( i > e > ?)
  6. Lowest MED
  7. eBGP path preferred over iBGP path
  8. Lowest IGP metric to BGP next-hop address
  9. Oldest Path
  10. Path from BGP router with lowest BGP RID <— Finally the RID has purpose!

So I have a better example for you to compare the above list too from R4’s “sh ip bgp” :

R4#sh ip bgp
BGP table version is 6, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i – IGP, e – EGP, ? – incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32       172.12.23.2                                               0 200 100 i
*>                        172.12.23.3                                               0 100 i
*  2.2.2.2/32       172.12.23.3                                               0 100 200 i
*>                         172.12.23.2              0                               0 200 i
*  3.3.3.3/32        172.12.23.2                                               0 200 100 i
*>                         172.12.23.3              0                               0 100 i
*> 4.4.4.4/32       0.0.0.0                      0                                  32768 i
*> 5.5.5.5/32       172.12.23.2                                                0 200 100 500 i

R4#

I really like the example to R5, as it shows not only the Transit AS’s (200 and 100) but then the final AS of the destination network in AS 500. Also notice that almost every remote loopback’s best path is the blank entry below it, like a whole different way of reading a route table only it’s an Advertisement table!

I’ve tried to format that output as best I could, though it may show up goofy on the post, however it would be good to go through that list of most considered to least for Path Selection.

After all that, I feel like I’ve gotten a BGP lobotomy, but I think the concepts are always the hardest, so onward we march.

Next up is examining how BGP routers determine Best-Path selection, so I HIGHLY ADVISE any readers to compare the list to “sh ip bgp” output so we are on the same page (though I will probably explain it anyways). *thump*