BGP best path and multipath
An edge router has four paths to one prefix. Some are thrown out before any comparing, such as paths whose next hop is inaccessible. BGP then takes the first valid path as best and compares it with each next path, through thirteen steps that start with highest weight and highest local preference. By default only the best path enters the routing table; BGP multipath installs more.
By Arif, founder of Daveth · Updated
The full 4 min walkthrough is in Daveth Pro (Network). See what the plan opens
What this page answers
What is the BGP best path selection order?
Thirteen steps, starting: highest weight, then highest local preference, then a locally originated path, through AS path length, origin and MED to the final tie-breakers. BGP compares the current best path with each next valid path in turn. Read it in “Thirteen steps, in order”
Which BGP paths are ignored in best path selection?
Paths marked as not synchronized, and paths whose NEXT_HOP is inaccessible, among others, are thrown out before any comparing. Read it in “Four copies of one route”
How does BGP multipath work?
By default BGP installs a single best path in the routing table. BGP multipath allows multiple BGP paths to the same destination to be installed together with the best path, for load sharing. Read it in “More than one path”
Four copies of one route
A company's staff use a payroll service at 203.0.113.0/24. The company buys internet access from two providers, ISP-A over two links and ISP-B over one. EDGE-1, the edge router, ends up with four routes to the payroll service, each called a path. Which one does it use?
Before any comparing, some paths are thrown out. Cisco's document lists when:
Routers ignore paths in these circumstances: Paths that are marked as not synchronized in the show ip bgp longer-prefixes output. Paths for which the NEXT_HOP is inaccessible. Be sure that there is an Interior Gateway Protocol (IGP) route to the NEXT_HOP that is associated with the path. Paths from an external BGP (eBGP) neighbor if the local autonomous system (AS) appears in the AS_PATH.
A next hop is simply the address traffic is handed to next. Synchronization is named in that list and not explained on this page.
Computed from the state: the four paths, before any comparison. No command prints it.
from AS_PATH LP type state ISP-A 1 64500 64999 100 eBGP goes on to the comparison ISP-A 2 64500 64999 100 eBGP goes on to the comparison ISP-B 64510 64510 64510 64999 100 eBGP goes on to the comparison CORE-1 64500 64999 100 iBGP ignored: next hop inaccessible
Look at CORE-1's row. Its path points at a backup circuit that has been removed, so it is ignored. It did not lose a comparison; it was never in one.
Thirteen steps, in order
Three paths are left. How does BGP pick one?
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.
The list: the thirteen steps, each step's first sentence.
1 Prefer the path with the highest WEIGHT. 2 Prefer the path with the highest LOCAL_PREF. 3 Prefer the path that was locally originated via a network or aggregate BGP subcommand or through redistribution from an IGP. 4 Prefer the path with the shortest AS_PATH. 5 Prefer the path with the lowest origin type. 6 Prefer the path with the lowest multi-exit discriminator (MED). 7 Prefer eBGP over iBGP paths. 8 Prefer the path with the lowest IGP metric to the BGP next hop. 9 Determine if multiple paths require installation in the routing table for BGP Multipath. 10 When both paths are external, prefer the path that was received first (the oldest one). 11 Prefer the route that comes from the BGP router with the lowest router ID. 12 If the originator or router ID is the same for multiple paths, prefer the path with the minimum cluster list length. 13 Prefer the path that comes from the lowest neighbor address.
Weight and LOCAL_PREF are values this router or its own company set; AS_PATH is the list of networks the route crossed. Read each step as a tie-breaker: a step only matters if every step above it came out equal.
And the directions are not consistent, which is where careless answers come from. Some steps want the higher value and some want the lower, so the winning direction has to be read per step rather than assumed once and carried down the list.
None of it matters if the next hop cannot be reached. A path can hold every attribute you wanted and still be unusable, because the gate comes before the ordering and an unreachable next hop never gets as far as being compared.
These factors summarize the order in which BGP evaluates the attributes for choosing the best path:
The Catalyst 9300 guide prints its own, shorter order, and it is not the same list. It has no oldest-path step: after the multipath check it goes straight to the lowest router ID. This page follows the support document's thirteen steps. By this course's reading of the 9300 list, ISP-A's two links would be split on router ID instead, and here the same link wins either way.
Computed from the state: each comparison, and the step that decided it. No command prints it.
ISP-A 1 beats ISP-A 2 step 10 ISP-A 1 beats ISP-B step 4
Computed from the state: the paths after the comparison. No command prints it.
from AS_PATH LP type state ISP-A 1 64500 64999 100 eBGP best, installed ISP-A 2 64500 64999 100 eBGP compared, not installed ISP-B 64510 64510 64510 64999 100 eBGP compared, not installed CORE-1 64500 64999 100 iBGP ignored: next hop inaccessible
Look at the two comparison rows. ISP-A's two links tie all the way to step 10, and the older one wins; ISP-B drops out at step 4 because it prepends its own AS twice, which makes its AS_PATH longer.
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). This comparison only occurs if the first (the neighboring) AS is the same in the two paths.
What does Cisco's own worked example look like? Notice that its last line names the reason that decided it.
From elsewhere: the document's own comparison of two paths. The names, numbers and addresses come from elsewhere, not from this scenario.
Comparing path 1 with path 2: Both paths have reachable next hops Both paths have a WEIGHT of 0 Both paths have a LOCAL_PREF of 100 Both paths are learned Both paths have AS_PATH length 1 Both paths are of origin IGP The paths have different neighbor AS's so ignoring MED Both paths are internal (no distinction is made between confed-internal and confed-external) Both paths have an IGP metric to the NEXT_HOP of 20645 Path 2 is better than path 1 because it has a lower Router-ID.
And what does the router's BGP table say about the winner?
From elsewhere: the start of the document's BGP table example. The names, numbers and addresses come from elsewhere, not from this scenario.
Router R1#show ip bgp vpnv4 rd 1100:1001 10.30.116.0/23 BGP routing table entry for 1100:1001:10.30.116.0/23, version 26765275 Paths: (9 available, best #6, no table)
Proves: That table output proves how many paths the router holds for the prefix and which one is best. Does not prove: the step that made it best, or whether a missing path lost or was never considered.
More than one path
ISP-A's second link is sitting idle. Can EDGE-1 use both ISP-A links for the payroll traffic?
A BGP routing process will install a single path as the best path in the routing information base (RIB) by default. The default value, when multipath is disabled, is 1. The default is to only enter the best path in the routing table. 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.
The list: the three multipath forms.
eBGP Multipath - maximum-paths n iBGP Multipath - maximum-paths ibgp n eiBGP Multipath - maximum-paths eibgp
So what do you type?
From elsewhere: the Catalyst 9300 guide's example. The names, numbers and addresses come from elsewhere, not from this scenario.
Device(config-router)# maximum-paths 8 or Device(config-router)# maximum-paths ibgp 2
From elsewhere, and its neighbor statement. The names, numbers and addresses come from elsewhere, not from this scenario.
Device(config-router)# neighbor 10.108.1.2 remote-as 65200
Configuration: EDGE-1's neighbors and maximum-paths 2, typed whole the first time the page shows them, in the forms these commands take; the addresses and AS numbers are this course's own.
EDGE-1# configure terminal EDGE-1(config)# router bgp 65001 EDGE-1(config-router)# neighbor 192.0.2.1 remote-as 64500 EDGE-1(config-router)# neighbor 192.0.2.5 remote-as 64500 EDGE-1(config-router)# neighbor 198.51.100.1 remote-as 64510 EDGE-1(config-router)# neighbor 10.0.0.2 remote-as 65001 EDGE-1(config-router)# maximum-paths 2 EDGE-1(config-router)# end
Proves: The configuration on EDGE-1 proves how many paths EDGE-1 is allowed to install for one prefix. Does not prove: that any path is a candidate. Candidacy depends on the attributes of the paths that arrive.
Both ISP-A paths are now installed. CORE-1 is inside the company and learns this route from EDGE-1. How many paths does it hear about?
BGP Multipath does not affect bestpath selection. For example, a router still designates one of the paths as the best path, per the algorithm, and advertises this best path to its neighbors. The maximum-paths command allows you to configure BGP to install multiple paths in the RIB for multipath load sharing. BGP uses the best path algorithm to still select a single multipath as the best path and advertise the best path to BGP peers.
Computed from the state: installed and advertised. No command prints it.
maximum-paths 2 installed ISP-A 1, ISP-A 2 advertised to CORE-1 ISP-A 1
Notice the last row. Installing two paths changes where the traffic goes; it does not change what the neighbors are told.
Load balancing over the multipaths is performed by CEF. BGP inserts up to n most recently received paths from multipath candidates in the IP routing table.
By this course's reading, the n in maximum-paths counts the best path too, so maximum-paths 2 means the best path and one more.
Who gets to share
ISP-B stops prepending, so its AS_PATH is now as short as ISP-A's, and maximum-paths goes to 3. Does ISP-B join in?
Configuration: maximum-paths 3, typed alone, in the forms these commands take; the addresses and AS numbers are this course's own.
EDGE-1# configure terminal EDGE-1(config)# router bgp 65001 EDGE-1(config-router)# maximum-paths 3 EDGE-1(config-router)# end
In order to be candidates for multipath, paths to the same destination need to have these characteristics equal to the best-path characteristics:
The list: what must equal the best path.
Weight Local preference AS-PATH length Origin MED One of these: Neighboring AS or sub-AS (before the addition of the eiBGP Multipath feature) AS-PATH (after the addition of the eiBGP Multipath feature)
The path must be learned from an external or confederation-external neighbor (eBGP). The IGP metric to the BGP next hop must be equal to the best-path IGP metric. If BGP multipath support is enabled and the EBGP paths are learned from the same neighboring autonomous systems, instead of a single best path, multiple paths are installed in the IP routing table.
Computed from the state, which paths are candidates. No command prints it.
ISP-A 2 candidate ISP-B not a candidate: neighboring AS differs
Computed from the state: installed and advertised. No command prints it.
maximum-paths 3 installed ISP-A 1, ISP-A 2 advertised to CORE-1 ISP-A 1
Look at ISP-B's row: not a candidate, because its neighboring AS differs. The neighboring AS is the first network in the AS_PATH, the provider the route came straight from. Same length is not enough; it has to be the same provider.
What about mixing eBGP and iBGP paths? Watch where the command is allowed to go.
From elsewhere: the eiBGP form, from the 17.x guide. The names, numbers and addresses come from elsewhere, not from this scenario.
Device(config)# router bgp 40000 Device(config-router)# address-family ipv4 vrf RED Device(config-router-af)# maximum-paths eibgp 6
The maximum-paths eibgp command can be configured only under the IPv4 VRF address family configuration mode and cannot be configured in any other address family configuration mode.
The company picks a provider
The company decides it prefers ISP-B, and an inbound policy on EDGE-1 sets ISP-B's LOCAL_PREF to 200. Which step decides now, and what happens to the ISP-A pair?
Computed from the state: each comparison. No command prints it.
ISP-A 1 beats ISP-A 2 step 10 ISP-B beats ISP-A 1 step 2
Computed from the state, which paths are candidates. No command prints it.
ISP-A 1 not a candidate: LOCAL_PREF, neighboring AS differ ISP-A 2 not a candidate: LOCAL_PREF, neighboring AS differ
Computed from the state: installed and advertised. No command prints it.
maximum-paths 3 installed ISP-B advertised to CORE-1 ISP-B
Look at the last comparison row. Thirteen steps, and this one was settled at step two. The ISP-A paths are no longer candidates, because their LOCAL_PREF no longer matches the new best path, so a single path is installed again.
By this course's observation, not a published figure, most real decisions end in the first few steps, where a company's own policy lives. The later steps matter mostly when everything above them was left equal, as it was for ISP-A's two links.
Which is the practical warning hiding in a thirteen-step list: a later step cannot rescue a path that lost at an earlier one. Change MED on a route whose LOCAL_PREF already settled the argument and the command succeeds, the attribute changes, and the decision does not move. You edited a round that was never reached.
So when a policy has no effect, find the step that decided before you look at the step you touched. The table names it, and that is the fastest question on the page.
Hold on to this
Ineligible paths never reach step one.
Now suppose the removed backup circuit comes back, and CORE-1's path to the payroll service becomes usable again. Would EDGE-1 install it alongside ISP-B? Start by predicting the deciding step for that path. By this course's reading: no. It is compared this time, but it is learned over iBGP, so it is not an eBGP multipath candidate, and it has a lower LOCAL_PREF than ISP-B.
The interactive lesson
The whole lesson, with its drawings and its questions. Free with a Daveth account.

