BGP Initialization:
- BGP starts by selecting the best path as the initial best path. The best path is not necessarily the first valid path, but rather the one that best fits the criteria set out in the BGP path selection process networkurge.com (opens in a new tab).
-
Weight Attribute:
- Cisco-specific: WEIGHT is a locally significant parameter that can be assigned to routes. Higher WEIGHT values are preferred, but this is only relevant within a single router community.cisco.com (opens in a new tab).
-
Local Preference Attribute:
- Paths with higher LOCAL_PREF values are preferred within the same AS. However, paths without LOCAL_PREF are treated as if they have a value of 100, not 0 as stated comparitech.com (opens in a new tab).
-
Origin:
- Paths originating from the local router via network or aggregate commands are indeed preferred community.cisco.com (opens in a new tab).
-
AS_PATH Length:
- Paths with shorter AS_PATH lengths are preferred. The
bgp bestpath as-path ignore
command can skip this step, but it's important to note that this command only ignores the AS_PATH length when determining the best path, it does not affect the calculation of the AS_PATH length community.cisco.com (opens in a new tab).
- Paths with shorter AS_PATH lengths are preferred. The
-
Origin Code:
- Paths with lower origin types are preferred: IGP < EGP < INCOMPLETE. This is correct, but it's worth noting that the EGP origin type is considered deprecated and is not used in modern BGP implementations comparitech.com (opens in a new tab).
-
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
andbgp bestpath med-confed
commands influence this step. -
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.
-
-
eBGP over iBGP Path
If the routes have the same Multi-Exit Discriminator (MED), the router will prefer external paths (eBGP - AD 20) over internal paths (iBGP - AD 200). This is because eBGP paths are typically more reliable and have a lower chance of being flapped (going up and down frequently due to network instability) networkurge.com (opens in a new tab).
- Shortest IGP Path
If BGP synchronization is disabled and only internal paths remain, the router will prefer the path through the closest Interior Gateway Protocol (IGP) neighbor. This means that the router prefers the shortest internal path (via IGP) within the Autonomous System (AS) to reach the destination (the shortest IGP path or the path with the lowest IGP metric to the BGP next-hop) networkurge.com (opens in a new tab).
- BGP Multipath
If the maximum-paths
command is configured, BGP will check if multiple paths to the destination prefix can be installed or not, based on the aforementioned criteria networkurge.com (opens in a new tab).
- Prefer Oldest Path
For eBGP paths, the router will select the oldest route. This is to minimize the effect of routes going up and down (flapping), which can cause unnecessary routing instability networkurge.com (opens in a new tab).
- Lowest Router ID
If the BGP Router IDs are the same, the router will prefer the route with the lowest neighbor BGP router ID value. This helps to ensure a stable and predictable routing path networkurge.com (opens in a new tab).
- Shortest Cluster-List
If the BGP route is originated by a peer and is received via multiple Internal Paths, the router will prefer the path with the minimum cluster-list length. This step is followed when BGP Route-Reflectors are present in the domain. The cluster-list is a list of all ASes in the path of the route, and the shorter the list, the closer the path is to the originating AS networkurge.com (opens in a new tab).
- Lowest Neighbor IP
If the BGP Router IDs are the same, the router will prefer the route with the lowest neighbor IP address. This helps to ensure a stable and predictable routing path networkurge.com (opens in a new tab).