CCNP-Studies
Routing
4-BGP
1.5 Bgp Best Path Selection Algorithm
  1. BGP Initialization:

    • BGP starts by selecting the first valid path as the initial best path.
  2. Weight Attribute:

    • Cisco-specific: WEIGHT is a locally significant parameter that can be assigned to routes. Higher WEIGHT values are preferred. This is only relevant within a single router.
  3. Local Preference Attribute:

    • Paths with higher LOCAL_PREF values are preferred within the same AS.
    • Paths without LOCAL_PREF are treated as if they have a value of 100.
  4. Locally Originated Paths:

  5. AS_PATH Length:

    • Paths with shorter AS_PATH lengths are preferred. The bgp bestpath as-path ignore command can skip this step.
    • Take note of the following:
      • If you have enabled the bgp bestpath as-path ignore command, this step is omitted.
      • An AS_SET is treated as a single entity, regardless of the number of ASs it contains.
      • The AS_CONFED_SEQUENCE and AS_CONFED_SET components are not factored into the calculation of the AS_PATH length."
  6. Origin Type:

    • Paths with lower origin types are preferred: IGP < EGP < INCOMPLETE.
  7. Multi-Exit Discriminator (MED):

    • The MED is considered under specific conditions, including when the first AS in the AS_SEQUENCE is the same in multiple paths. The bgp always-compare-med and bgp bestpath med-confed commands influence this step.

    • multi-exit discriminator (MED) (opens in a new tab)

    • MEDs are compared between paths only if the first AS in the AS_SEQUENCE is the same for multiple paths. Any AS_CONFED_SEQUENCE that precedes is ignored. This means that MEDs are compared when multiple paths share the same initial AS.

    • If the bgp always-compare-med command is enabled, MEDs are compared for all paths. However, it is essential to exercise caution when enabling this option, as it can potentially lead to routing loops. Disabling this option across the entire Autonomous System (AS) is advisable to prevent routing issues.

    • Enabling the bgp bestpath med-confed command ensures that MEDs are compared for all paths consisting solely of AS_CONFED_SEQUENCE. These paths typically originate within the local confederation.

    • When paths are received from a neighbor with a MED value of 4,294,967,295, the MED is adjusted before insertion into the BGP table. It is changed to 4,294,967,294.

    • Paths received from a neighbor with a MED of 4,294,967,295 are considered valid and are inserted into the BGP table. This behavior aligns with fixes for Cisco bug ID CSCef34800.

    • Paths that lack a MED value are assigned a MED of 0 unless you have enabled the bgp bestpath med missing-as-worst option. If this option is enabled, these paths are assigned a MED of 4,294,967,294. It's important to note that this behavior also aligns with the changes introduced due to Cisco bug ID CSCef34800.

    • Additionally, the bgp deterministic-med command can influence the MED comparison process. For a practical demonstration of how BGP routers use the Multi-Exit Discriminator for best path selection, refer to the documentation.

  8. eBGP Over iBGP:

    • eBGP paths are preferred over iBGP paths.
    • eBGP paths are preferred over iBGP paths. It's important to note that paths containing AS_CONFED_SEQUENCE and AS_CONFED_SET are local to the confederation. As a result, these paths are treated as internal paths, and there is no distinction between Confederation External and Confederation Internal.
    • Give preference to the path with the lowest IGP metric to reach the BGP next hop.
    • Continue with the selection process, even if the best path is already chosen.
  9. Multipath:

  • Assess whether multiple paths should be added to the routing table for BGP Multipath.
  • Continue this evaluation if the best path hasn't been selected yet.
    • In the case of multiple external paths, prioritize the path that was initially received (the oldest one). This approach reduces route flapping, ensuring that a newer path doesn't displace an older one, even if the newer path would be favored by subsequent decision criteria in Steps 11, 12, and 13.
      • You can skip this step if any of the following conditions are met:
      • The bgp best path compare-routerid command is enabled. bgp best path compare-routerid (opens in a new tab)
      • Router IDs are identical across multiple paths due to their origin from the same router.
      • No current best path exists.
      • The current best path is lost, for example, when the neighbor offering
  1. Lowest Router ID:

    • Preference is given to the route from the BGP router with the lowest router ID, which is typically the highest IP address on the router.
    • When a path includes Route Reflector (RR) attributes, the originator ID replaces the router ID in the path selection process.
  2. Originator Router ID:

    • If multiple paths share the same originator or router ID, give preference to the path with the shortest cluster list length.
    • This specific scenario is encountered in BGP Route Reflector (RR) environments, enabling clients to establish connections with RRs or clients in different clusters. In this context, clients need to be knowledgeable about the RR-specific BGP attribute.
  3. Lowest Neighbor Address:

  • Prefer the path that comes from the lowest neighbor address.
  • This address is the IP address that is used in the BGP neighbor configuration. The address corresponds to the remote peer that is used in the TCP connection with the local router.

Source: Cisco Documentation (opens in a new tab)