BGP Best Path Selection Algorithm
Introduction
Prerequisites
Requirements
Components Used
Conventions
Why Routers Ignore Paths
How the Best Path Algorithm Works
Customize the Path Selection Process
BGP Multipath
NetPro Discussion Forums ? Featured Conversations Related Information
Border Gateway Protocol (BGP) routers typically receive multiple paths to the same destination. The BGP best path algorithm decides which is the best path to install in the IP routing table and to use for traffic forwarding.
There are no specific requirements for this document.
This document is not restricted to specific software and hardware versions.
Refer to Cisco Technical Tips Conventions for more information on document conventions.
Assume that all paths that a router receives for a particular prefix are arranged in a list. The list is similar to the output of the show ip bgp longer?prefixes command. In this case, some paths are not considered as candidates for the best path. Such paths typically do not have the valid flag in the output of the show ip bgp longer?prefixes command. Routers ignore paths in these circumstances:
If BGP synchronization is enabled, there must be a match for the prefix in the IP routing table in order for an internal BGP (iBGP) path to be considered a valid path. BGP synchronization is enabled by default in Cisco IOS? Software. If the matching route is learned from an Open Shortest Path First (OSPF) neighbor, its OSPF router ID must match the BGP router ID of the iBGP neighbor. Most users prefer to disable synchronization with use of the no synchronization BGP subcommand.
Note: Synchronization is disabled by default in Cisco IOS Software Release 12.2(8)T and later.
Be sure that there is an Interior Gateway Protocol (IGP) route to the NEXT_HOP that is associated with the path.
AS_PATH
Such paths are denied upon ingress into the router and are not even installed in the BGP Routing Information Base (RIB). The same applies to any path that is denied by a routing policy that is implemented via access, prefix, AS_PATH, or community lists, unless you have configured soft?reconfiguration inbound for the neighbor.
In this case, the router sends a notification and closes the session.
The policy has rejected these paths. However, the router has stored the paths because you have configured soft?reconfiguration inbound for the neighbor that sends the path.
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. This list provides the rules that are used to determine the best path:
Note: WEIGHT is a Cisco?specific parameter. It is local to the router on which it is configured.
Note: A path without LOCAL_PREF is considered to have had the value set with the bgp default local?preference command, or to have a value of 100 by default.
Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate?address command.
Note: Be aware of these items:
? This step is skipped if you have configured the bgp bestpath as?path ignore command.
? An AS_SET counts as 1, no matter how many ASs are in the set.
? The AS_CONFED_SEQUENCE and AS_CONFED_SET are not included in the AS_PATH length.
Note: IGP is lower than Exterior Gateway Protocol (EGP), and EGP is lower than INCOMPLETE.
Note: Be aware of these items:
? This comparison only occurs if the first (the neighboring) AS is the same in the two paths. Any confederation sub?ASs are ignored.
In other words, MEDs are compared only if the first AS in the AS_SEQUENCE is the same for multiple paths. Any preceding AS_CONFED_SEQUENCE is ignored.
? If bgp always?compare?med is enabled, MEDs are compared for all paths.
You must disable this option over the entire AS. Otherwise, routing loops can occur.
? If bgp bestpath med?confed is enabled, MEDs are compared for all paths that consist only of AS_CONFED_SEQUENCE.
These paths originated within the local confederation.
? THE MED of paths that are received from a neighbor with a MED of 4,294,967,295 is changed before insertion into the BGP table. The MED changes to to 4,294,967,294.
? Paths received with no MED are assigned a MED of 0, unless you have enabled bgp bestpath med missing?as?worst .
If you have enabled bgp bestpath med missing?as?worst, the paths are assigned a MED of 4,294,967,294.
? The bgp deterministic med command can also influence this step.
Refer to How BGP Routers Use the Multi?Exit Discriminator for Best Path Selection for a demonstration.
If bestpath is selected, go to Step 9 (multipath).
Note: Paths that contain AS_CONFED_SEQUENCE and AS_CONFED_SET are local to the
confederation. Therefore, these paths are treated as internal paths. There is no distinction between Confederation External and Confederation Internal.
Continue, even if bestpath is already selected.
Continue, if bestpath is not yet selected.
This step minimizes route?flap because a newer path does not displace an older one, even if the newer path would be the preferred route based on the next decision criteria (Steps 11, 12, and 13).
Skip this step if any of these items is true:
? You have enabled the bgp best path compare?routerid command.
Note: Cisco IOS Software Releases 12.0.11S, 12.0.11SC, 12.0.11S3, 12.1.3, 12.1.3AA, 12.1.3.T, and 12.1.3.E introduced this command.
? The router ID is the same for multiple paths because the routes were received from the same router.
? There is no current best path.
The current best path can be lost when, for example, the neighbor that offers the path goes down.
The router ID is the highest IP address on the router, with preference given to loopback addresses. Also, you can use the bgp router?id command to manually set the router ID.
Note: If a path contains route reflector (RR) attributes, the originator ID is substituted for the router ID in the path selection process.
This is only present in BGP RR environments. It allows clients to peer with RRs or clients in other clusters. In this scenario, the client must be aware of the RR?specific BGP attribute.
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.
The extended community attribute, which is called BGP Cost Community, provides a way to customize the best path selection process. An additional step, in which Cost Communities are compared, is added to the algorithm that the How the Best Path Algorithm Works section describes. This step comes after the required step (point of insertion) in the algorithm. The path with the lowest cost value is preferred.
Note: Be aware of these items:
BGP Multipath allows installation into the IP routing table of multiple BGP paths to the same destination. These paths are installed in the table together with the best path for load sharing. BGP Multipath does not affect bestpath selection. For example, a router still designates one of the paths as the best path, according to the algorithm, and advertises this best path to its neighbors.
These are the BGP Multipath features:
In order to be candidates for multipath, paths to the same destination need to have these characteristics equal to the best?path characteristics:
? Neighboring AS or sub?AS (before the addition of the eiBGP Multipath feature)
? AS?PATH (after the addition of the eiBGP Multipath feature) Some BGP Multipath features put additional requirements on multipath candidates.
These are the additional requirements for eBGP multipath:
These are the additional requirements for iBGP multipath:
BGP inserts up to n most recently received paths from multipath candidates in the IP routing table. The maximum value of n is currently 6. The default value, when multipath is disabled, is 1.
For unequal?cost load balancing, you can also use BGP Link Bandwidth.
Note: The equivalent next?hop?self is performed on the best path that is selected among eBGP multipaths before it is forwarded to internal peers.
Networking Professionals Connection is a forum for networking professionals to share questions, suggestions, and information about networking solutions, products, and technologies. The featured links are some of the most recent conversations available in this technology.
NetPro Discussion Forums ? Featured Conversations for RP |
Service Providers: MPLS |
Virtual Private Networks: Services |
Virtual Private Networks: Security |
Contacts & Feedback | Help | Site Map
? 2008 ? 2009 Cisco Systems, Inc. All rights reserved. Terms & Conditions | Privacy Statement | Cookie Policy | Trademarks of Cisco Systems, Inc.
Updated: May 24, 2006 Document ID: 13753