BGP Path Selection

Run a Speed Test

A large network often hears about the same destination from several directions at once — multiple valid paths to the same block of addresses. BGP must pick exactly one to use. How it chooses is one of the most consequential and misunderstood processes on the internet, because the answer is driven not by speed or distance but by policy. Understand the decision ladder BGP climbs and you understand why internet traffic so often takes a path that looks nothing like the shortest line on a map.

One Destination, Many Paths

BGP is the protocol that stitches the internet's autonomous systems together, and a well-connected network commonly receives several advertisements for the same destination prefix — one through each provider or peer it connects to. BGP installs only one best path per destination in the routing table, so it needs a deterministic way to rank the candidates and choose.

It does this with an ordered decision process: a fixed sequence of criteria, applied one at a time. BGP compares the candidate paths against the first criterion; if that produces a single winner, it stops and selects it. Only if the paths tie on that criterion does it move to the next. The order is everything — a path can be objectively longer yet still win, simply because an earlier, higher-priority criterion favoured it.

The Decision Ladder

The selection process has many steps, but a handful do almost all the real work. Here they are in priority order, highest first:

OrderCriterionPreferControls
1Weight (vendor-specific)HighestLocal to one router
2Local preferenceHighestOutbound, across the AS
3Locally originatedPrefer own routes
4AS-path lengthShortestFewest AS hops
5Origin typeLowestHow the route was learned
6MEDLowestInbound, between two ASes
7+eBGP over iBGP, lowest IGP cost, tie-breakersFinal decisions

The two you will hear about most are local preference and AS-path length, because they sit near the top and are the main levers operators use. The rest mostly act as tie-breakers when those do not decide.

Local Preference: Policy Wins First

After the vendor-specific weight (which only affects a single router), the first network-wide criterion is local preference — and the fact that it comes before AS-path length is the single most important thing to understand about BGP selection. Local preference is a value an operator sets to express "this is the exit I want outbound traffic to use," with higher being preferred. Because it ranks above path length, it lets a network override the shortest path entirely.

Why would you do that? Money and performance. Suppose a network connects to two providers: an expensive premium link and a cheaper one. The cheaper provider might advertise a longer AS-path, but by setting a higher local preference on its routes, the operator steers outbound traffic out the cheaper link anyway. The shortest path loses to the preferred path. This is BGP being, at its core, a policy protocol — it routes by business intent first, and only falls back to path length when no policy distinguishes the options.

AS-Path Length: the Shortest-Path Proxy

When local preference ties — common between equally-rated providers — BGP turns to AS-path length. Every BGP route carries the list of autonomous systems it has traversed (the AS-path), and BGP prefers the route that crosses the fewest. The reasoning is that fewer AS hops is a rough proxy for a more direct path.

The word "rough" is doing a lot of work, though. AS-path length counts networks, not miles or milliseconds. One AS might span a single city; another might stretch across a continent. A two-AS path could be physically far longer and slower than a three-AS path. So while AS-path length is simple and policy-neutral, it is a coarse measure that says nothing about actual performance. Operators also exploit this deliberately through AS-path prepending — artificially lengthening their advertised path to make a route look less attractive and shift inbound traffic elsewhere.

MED, the Tie-Breakers, and the Big Misconception

Further down the ladder, MED (Multi-Exit Discriminator) handles a narrower job: when two networks connect at multiple points, one can send a MED value to hint which entry point the other should use for inbound traffic, lower being preferred. Unlike local preference, MED is a suggestion to a neighbour rather than an internal decision, and because it sits low in the order it only matters once the higher criteria tie. Below it come final tie-breakers — preferring routes learned from external BGP peers over internal ones, then the lowest interior (IGP) cost to the next hop, and ultimately mechanical tie-breakers like the lowest router ID to guarantee a deterministic choice.

All of this leads to the misconception worth dispelling: BGP does not pick the fastest route. It measures no latency, no bandwidth, no geography. Its best path is the one that best satisfies policy and, failing that, has the fewest AS hops. This is why traffic between two nearby cities can detour through a distant one, and why "the internet found a slow path" is usually BGP faithfully following policy and path-length rules that have nothing to do with speed. The system optimises for control and stability across a network of independent operators — not for the shortest travel time of any individual packet. For the protocol mechanics underneath this selection, see BGP explained.

Frequently Asked Questions

How does BGP choose the best path?

It runs candidate paths through an ordered list of criteria and picks the first winner. The key steps, in order, are highest local preference, shortest AS-path, lowest origin type, and lowest MED, plus tie-breakers. As soon as one criterion distinguishes the paths, BGP selects that path and ignores later criteria.

What is local preference in BGP?

A value set within an autonomous system indicating its preferred exit for outbound traffic, higher being preferred. It is the first major tie-breaker, so it lets an operator override path length and steer traffic out a chosen link — say a cheaper provider — regardless of which path looks shortest.

Why does BGP prefer the shortest AS-path?

The AS-path lists the autonomous systems a route crosses, and fewer hops is a rough proxy for a more direct path. When local preference doesn't decide, BGP picks the fewest AS hops. It counts networks, not distance or speed, so it is coarse but simple and policy-neutral.

What is MED in BGP?

The Multi-Exit Discriminator — a hint one AS sends a neighbor to suggest which entry point into its network to use, lower preferred. It influences inbound traffic when two networks connect at multiple points, and is considered late, so it only matters when earlier criteria tie.

Is BGP path selection based on speed or distance?

No. BGP measures no latency, bandwidth, or geography. Selection rests on policy attributes like local preference and on AS-path length, which counts networks not performance. So the best path matches routing policy, not necessarily the fastest route — which often surprises people.

Related Guides

More From This Section