BGP4 Best Path Selection Algorithm
When multiple paths for the same route prefix are known to a BGP4 device, 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.
Refer to the Brocade FastIron Command Reference for more information.
- Verify that the next hop can be resolved by means of Interior Gateway Protocol (IGP).
- Use the path with the largest weight.
- If the weights are the same, prefer the path with the largest local preference.
- Prefer the route that was self-originated locally.
- 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.
- 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:
- 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 if and only if the routes were learned from the same neighboring AS. 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 AS information in the paths, the
always-compare-medcommand can be used. This option is disabled by default.The
med-missing-as-worstcommand 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 within the local AS or confederation, unless the
compare-med-empty-aspathcommand is configured. - Prefer paths in the following order:
- 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 inside the AS to reach the destination.
- If the internal paths also are the same and BGP4 load sharing is enabled, load-share
among the paths. Otherwise go to Step 11.
Note: For eBGP routes, load sharing applies only when the paths are from neighbors within the same remote AS. eBGP paths from neighbors in different ASs are not compared, unless multipath multi-as is enabled.
- If
compare-routeridis 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. - Prefer the path with the minimum cluster-list length.
- Prefer the route that comes from the lowest BGP4 neighbor address.