Aut inveniam viam aut faciam

BGP Best Path Selection Algorithm

BGP Best Path Selection Algorithm

http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html

BGP Cost Community

https://www.cisco.com/c/en/us/td/docs/ios/12_0s/feature/guide/s_bgpcc.html

Why Routers Ignore Paths:

– path are marked “not synchronized” in sh ip bgp long-prefixes output

– next hop is inaccessible

– path from eBGP neighbor has local AS in AS_PATH

bgp enforce-first-as is set and the update doesn’t list the neighbor AS as the first AS

– paths are marked “receive only” in sh ip bgp long-prefixes output

Best Path Algorithm:

Note: if extended community cost is configured for pre-bestpath, compare before anything else

-> lowest is best

-> set extcommunity cost pre-bestpath <community-id> <cost>

-> bgp bestpath cost-community ignore

-> this command was intended only to assist in troubleshooting path selection

– Important, next hop needs to be valid

– It’s not that difficult to remember whether higher or lower is best.  With the first two (weight and local_preference), highest is best.  Everything else, lowest, shortest, or oldest is best.

– The steps below include the configuration commands that can modify the default behavior of each step.

 1.  weight

-> highest is best

-> Cisco proprietary

-> locally significant

-> range 0 to 65,535

-> default is 0 for received routes

-> default is 32768 for locally generated routes

-> route-map WEIGHT permit 10

->   set weight 40000

-> neighbor 1.1.1.1 route-map WEIGHT in

-> neighbor 1.1.1.1 default-originate route-map WEIGHT in

-> network 1.1.1.0 mask 255.255.255.0 route-map WEIGHT

-> This works.  As does applying the route-map to the redistribute and aggregate-address commands.  But why would you do this to locally originated routes since it’s only locally significant.

 

2.  local_preference

-> highest is best

-> significant only in the local AS

-> range 0 to 4294967295

     -> default 100 for every route

-> bgp default local-preference 200

-> route-map LP permit 10

->   set local-preference 200

-> neighbor 1.1.1.1 route-map LP in

-> neighbor 1.1.1.1 default-originate route-map LP in

-> redistribute eigrp 1 route-map LP

-> redistribute ospf 1 route-map LP match internal external 1 external 2

-> network 1.1.1.0 mask 255.255.255.0 route-map LP

-> aggregate-address 1.1.2.0 255.255.255.252 attribute-map LP

 3.  locally originated path

-> locally generated routes are preferred over received routes

-> network command

-> aggregate-address command

-> redistribute command

 4.  AS_PATH

-> shortest is best

-> bgp bestpath as-path ignore

-> route-map PREPEND permit 10

->   set as-path prepend 100 100

-> neighbor 1.1.1.1 route-map PREPEND out

 5.  ORIGIN

-> lowest type is best

-> IGP < EGP < INCOMPLETE

 

6.  multi-exit discriminator (MED)

-> metric

-> lowest is best

-> range 0 to 65,535

-> default is 0 for received routes

-> when MED is not assigned

-> set to the value of the IGP metric for routes injected into BGP

-> network or redistribute commands

-> used to influence a neighboring AS with multiple entry points

-> or a neighboring AS may be influencing the local AS with multiple entry points

     -> compared only if the first AS in the AS_SEQUENCE is the same for multiple paths

     -> confederation sub-ASs are ignored unless configured

     -> bgp deterministic-med

         -> compare routes advertised by different peers in the same AS

-> bgp always-compare-med

         -> compare routes advertised by different ASs.

-> if used, must be configured in the entire AS to prevent routing loops

     -> bgp bestpath med confed

         -> compare all paths that consist only of AS_CONFED_SEQUENCE

-> bgp bestpath med confed missing-as-worst

-> bgp bestpath med missing-as-worst

-> route-map MED permit 10

->   set metric 100

-> neighbor 1.1.1.1 route-map MED out

-> neighbor 1.1.1.1 default-originate route-map MED out

-> redistribute eigrp 1 metric 100

-> redistribute ospf 1 metric 100 match internal external 1 external 2

-> redistribute eigrp 1 route-map MED

-> redistribute ospf 1 route-map MED match internal external 1 external 2

-> network 1.1.1.0 mask 255.255.255.0 route-map MED

-> aggregate-address 1.1.2.0 255.255.255.252 attribute-map MED

 7.  eBGP over iBGP

-> paths that contain as_confed_sequence and as_confed_set are considered internal

 8.  IGP metric

-> lowest is best

-> bgp bestpath igp-metric ignore

9.  extended community cost

-> IGP point of insertion (POI)

-> lowest is best

-> route-map EXTCOMMUMITYCOST permit 10

->   set extcommunity cost 1 1

-> route-map EXTCOMMUMITYCOST permit 10

->   set extcommunity cost igp 1 1

-> neighbor 1.1.1.1 route-map EXTCOMMUMITYCOST out

-> neighbor 1.1.1.1 default-originate route-map EXTCOMMUMITYCOST out

-> redistribute eigrp 1 route-map EXTCOMMUMITYCOST

-> redistribute ospf 1 route-map EXTCOMMUMITYCOST match internal external 1 external 2

-> network 1.1.1.0 mask 255.255.255.0 route-map EXTCOMMUMITYCOST

-> aggregate-address 1.1.2.0 255.255.255.252 attribute-map EXTCOMMUMITYCOST

10.  multipath

-> if multiple paths match the above steps,

-> determine if multiple paths require installation into the routing table

-> default, only one best path is installed into the routing table

-> maximum-paths 2

-> maximum-paths eibgp 2

-> maximum-paths ibgp 2

 

11.  oldest route

-> when multiple paths are external, prefer the path that was received first

-> oldest is best

-> this step can be skipped by forcing BGP to compare router-ids

-> bgp bestpath compare-router-id

 12.  router-id

-> lowest is best

 

13.  cluster length

-> lowest is best

-> router reflectors only

 

14.  neighbor address

-> lowest is best

Comments are closed.

This entry was posted on Thursday, December 30th, 2021 at 10:14 am and is filed under CCIE. You can follow any responses to this entry through the RSS 2.0 feed. Responses are currently closed, but you can trackback from your own site.