BGP AS_SET Not Used In AS-Path Length Comparison / BGP Route Selection

By | January 5, 2021

One day, When I was working on a issue in production environment, my colleague came to me with a query which was related to on going issue.

As per him, BGP route selection was not happening in right way. He was saying that a route is selecting which is having longest AS_Set and it is not accepted behavior.

I was checked and confused on it. So I decided to check it in LAB environment.

I came on conclusion post the LAB testing that AS_set is not used in BGP route selection or in AS path comparison. Actually, One AS_set considers as one AS.

Below is our topology:

BGP AS_SET Not Used In AS-Path Length Comparison / BGP Route Selection

R1 is receiving 192.168.0.0/16 aggregated prefix from R2 and R3 as below:

R1#sho ip bgp | be Net
   Network          Next Hop     Metric LocPrf Weight Path
*  192.168.0.0/16   192.168.7.7      0             0 77 {88,90} i
*>                  192.168.5.5      0             0 55 {66,60,666,30} i

As you can see R1 preferring the second route which is having longest AS_Set.

R1#sh ip bgp 192.168.0.0
BGP routing table entry for 192.168.0.0/16, version 4
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
     1        
  77 {88,90}, (aggregated by 77 192.168.100.7)
    192.168.7.7 from 192.168.7.7 (192.168.100.7)
      Origin IGP, metric 0, localpref 100, valid, external
  55 {66,60,666,30}, (aggregated by 55 192.168.200.5)
    192.168.5.5 from 192.168.5.5 (192.168.200.5)
      Origin IGP, metric 0, localpref 100, valid, external, best

If you will see the above output you will realize that all the parameters are equal. Now only one thing is left which we need to check that is reception time of routes. Looks like, most recent path is selecting. So Iā€™m going to reset the BGP peers.

R2#clear ip bgp *
*Jan  1 01:34:11.475: %BGP-5-ADJCHANGE: neighbor 192.168.5.4 Down User reset
*Jan  1 01:34:11.479: %BGP-5-ADJCHANGE: neighbor 192.168.6.6 Down User reset
*Jan  1 01:34:11.667: %BGP-5-ADJCHANGE: neighbor 192.168.6.6 Up
*Jan  1 01:34:12.287: %BGP-5-ADJCHANGE: neighbor 192.168.5.4 Up



Below is the output from R1, Just after re-establish the BGP sessions:

R1#sho ip bgp | be Net  
   Network          Next Hop     Metric LocPrf Weight Path
*  192.168.0.0/16   192.168.5.5      0             0 55 {66,60,666,30} i
*>                  192.168.7.7      0             0 77 {88,90} i
R1#

You can see the above result, Now R1 preferring the route which is having shortest AS_Set. So it proves that AS_Set considers as an single AS and if AS-path is same and all other attributes are also equal then a most recent route prefers.

Leave a Reply

Your email address will not be published.