OcNOS-SP : Layer 3 Guide : Layer 3 Unicast Configuration Guide : BGP : BGP Best Path Selection Process
BGP Best Path Selection Process
BGP assigns the first valid path as the current best path. BGP then compares the best path with the next path in the list, until BGP reaches the end of the list of valid paths. Below steps provides the rules that are used to determine the best path:
1. Prefer the path with the highest WEIGHT.
2. Prefer the path with the highest LOCAL_PREF.
3. Prefer the path that was locally originated via a network or aggregate BGP subcommand or through redistribution from an IGP.
4. Prefer the path with the shortest AS_PATH.
Note: Beware of these items:
This step is skipped if user has configured the bgp bestpath as-path ignore command.
If bgp bestpath compare-confed-aspath is configured then Prefer the path with the shortest AS_CONFED path.
5. Prefer the path with the lowest ORIGIN type.
Note: Beware of below listed items:
IGP is lower than Exterior Gateway Protocol (EGP), and EGP is lower than INCOMPLETE.
6. Prefer the path with the lowest multi-exit discriminator (MED).
Note: Beware of these items:
By default, MED is compared in these cases:
MEDs are compared only if the first AS in the AS_SEQUENCE is the same for multiple paths
If both the paths are internal as routes
If paths have confederation as-path then MEDs are compared only if the first AS in the BGP_AS_CONFED_SEQUENCE is the same for multiple paths
To override all above checks, user can configure bgp always-compare-med command
7. Prefer eBGP over iBGP paths.
Note: Beware of below listed item:
EBGP is preferred over IGBP or EBGP is preferred over CONFED.
8. Path learned from LU Address-family is preferred over IPv4 Unicast Address-family.
Note: Beware of these items:
This is Exception Rule for IPv4 Labeled-Unicast Address-family.
This rule applicable only for IPv4 Labeled-Unicast/Unicast routes over default VRF.
9. Prefer the path with the lowest IGP metric to the BGP next hop.
10. Determine if multiple paths require installation in the routing table for BGP Multipath and mark the ECMP candidate.
11. When both paths are external, prefer the path that was received first (the oldest one). This step minimizes route-flap, since a newer path won't displace an older one, even if it was the preferred route based on the additional decision criteria below. This has to be enabled by BGP command bestpath tie-break-on-age
Note: Beware of these items:
Skip this step if any of these items are true:
If bgp bestpath compare-routerid is configured in addition to bestpath tie-break-on-age, then this step will be skipped.
If the router ID is same for multiple paths, because the routes were received from the same router, then this step will be skipped.
12. Router ID and Originator Id:
If bgp bestpath compare-routerid is configured, then prefer the route that comes from the BGP router with the lowest Router ID.
If bgp bestpath dont-compare-originator-id is not configured, prefer the route that comes from the BGP router with the lowest Router ID.
Note: Beware of the below listed item:
If a path contains Route Reflector (RR) attributes, the Originator ID is substituted for the Router ID in the path selection process.
If bgp bestpath dont-compare-originator-id is configured, prefer the route that comes from the BGP router with the lowest router ID. In this case, Originator ID is not compared even if the RR attribute is present.
13. If the originator or Router ID is the same for multiple paths, prefer the path with the minimum cluster list length.
Prefer the path that comes from the lowest neighbor address.
Last modified date: 10/16/2023