Because most online material / books does not summarize the full algorithm or does not summarize all the steps it is harder to troubleshoot a BGP issue. In order to change the routing in your desired way, you should understand why the current best path is selected.
Here is a summary of all the 13 comparison steps of the best path selection algorithm of Cisco IOS..
(01) Weight (highest preferred,)
(02) Local Preference (highest preferred)
(03) Origination (local originate, next-hop 0.0.0.0 preferred)
(04) AS Path (shortest preferred)
(05) Origin Code (i preferred over ?)
(06) MED (lowest preferred, compared if routes learned from same AS by default)
(07) Path Type (external preferred over internal)
(08) IGP metric to Next-hop (lowest preferred, if equal go to next step)
(09) Multipath configured check (if configured, install in local routing table and go to next step)
(10) Age of the Route (oldest preferred, compares for external routes only)
(11) Router ID (lowest preferred, Originator ID is used as router-id for routes learned from RRs)
(12) Cluster List length (shortest preferred, learned from clients preferred over non-clients)
(13) Neighbor ID (lowest preferred)
Following are some facts associated with the attributes and links to some practical examples where they are used to manipulate routing..
Weight
- Default Weight is 32768 for locally originated routes
- Cisco proprietary
- Locally significant
BGP Path Selection by Weight
Local Preference
- Default Weight is 100 for all iBGP/eBGP originated routes
- Customized Local Preference is not advertised to eBGP peers
- Carried through confederation eBGP
BGP Path Selection by Local Preference
Origination
- Locally originated routes have next-hop 0.0.0.0
- Include routes from network / aggregate-address commands, redistribution
BGP Path Selection by Origination
AS Path
BGP Path Selection by AS-Path
Origin Code
- Status codes i>e>?
BGP Path Selection by Origin Code
MED
- Only compared for prefixes learned by same AS by default
BGP Path Selection by MED (Multi-Exit Discriminator)
BGP Path Selection by MED for Routes Learned from Different ASes
Paths
BGP Path Selection by Path Type (eBGP vs iBGP) and Hidden Local Preference
IGP metric to Next-hop
Multipath
- If the IGP metric to the next hop is equal and if configured to use multipath, the routes will be installed in routing table of the local router.
- But will select one best route to advertise neighbors through next steps
Age of the Route
- Compared only for eBGP routes.
Router ID
- Originator ID is used as router-id for routes learned from RRs
BGP Path Selection by Router ID
Cluster List length
- Learned from clients preferred over non-clients
Neighbor ID
Commands to Change the Default Behavior
AS-Path
- Hidden command to ignore AS path lookup
- bgp bestpath as-path ignore
MED
- bgp always-compare-med
- bgp bestpath med-confed
compares MED for routes locally originated in the confederation
- bgp bestpath med missing-as-worst
assign MED of 4294967294 to null MED
- bgp deterministic med
compare MED against all possible paths
IGP Metric
- bgp bestpath igp-metric ignore
- Introduced in IOS-XE 3.4S
Multipath
- Hidden command to allow multi-path if AS_PATH is not the same (has to be same length)
bgp bestpath as-path multipath-relax
- maximum-paths [ibgp|eibgp] is used to configure load balancing
Router ID
- no bgp bestpath compare-router id
Further Reference:
https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html
Practicals & Notes by CCDE #20240056
No comments:
Post a Comment