BGP4 Best Path Selection Algorithm

The BGP decision process is applied to the routes in the Routing Information Base, Incoming (RIB-In), which contains routes learned from inbound UPDATE messages. The output of the decision process is the set of routes that will be advertised to BGP speakers in local or remote autonomous systems and stored in the Adjacency RIB, Outgoing (RIB-Out).

The device uses the following algorithm to weigh the paths and determine the optimal path for the route. The optimal path depends on various parameters, which can be modified.

  1. Verify that the next hop can be resolved by means of the Interior Gateway Protocol (IGP).
  2. Use the path with the largest weight.
  3. If the weights are the same, prefer the path with the largest local preference.
  4. Prefer the route that was self-originated locally.
  5. If the local preferences are the same, prefer the path with the shortest AS-path. An AS-SET counts as 1. A confederation path length, if present, is not counted as part of the path length.

    The as-path ignore command disables the comparison of the AS path lengths of otherwise equal paths.

    This step can be skipped if the as-path-ignore command is configured.

  6. If the AS-path lengths are the same, prefer the path with the lowest origin type. From low to high, route origin types are valued as follows:
    • IGP is lowest.
    • EGP is higher than IGP but lower than INCOMPLETE.
    • INCOMPLETE is highest.
  7. If the paths have the same origin type, prefer the path with the lowest MED.

    The device compares the MEDs of two otherwise equivalent paths only if the routes were learned from the same neighboring autonomous system. This behavior is called deterministic MED. Deterministic MED is always enabled and cannot be disabled.

    To ensure that the MEDs are always compared, regardless of the autonomous system information in the paths, the always-compare-med command can be used. This option is disabled by default.

    The med-missing-as-worst command can be used to make the device regard a BGP4 route with a missing MED attribute as the least-favorable path when the MEDs of the route paths are compared.

    MED comparison is not performed for internal routes that originate in the local autonomous system or confederation, unless the compare-med-empty-aspath command is configured.

  8. Prefer paths in the following order:
    • Routes received through EGP from a BGP4 neighbor outside of the confederation
    • Routes received through EGP from a BGP4 device in the confederation or routes received through IGP.
  9. If all the comparisons are equal, prefer the route with the lowest IGP metric to the BGP4 next hop. This is the closest internal path in the autonomous system to reach the destination.
  10. If the internal paths are the same and BGP4 load sharing is enabled, load share among the paths. Otherwise go to Step 11.
    Note

    Note

    For EGP routes, load sharing applies only when the paths are from neighbors in the same remote autonomous system. EGP paths from neighbors in different autonomous systems are not compared, unless multipath multi-as is enabled.
  11. If compare-routerid is enabled, prefer the path that comes from the BGP4 device with the lowest device ID. If a path contains originator ID attributes, then the originator ID is substituted for the router ID in the decision.
  12. Prefer the path with the minimum cluster-list length.
  13. Prefer the route that comes from the lowest BGP4 neighbor address.