How the Border Gateway Protocol (BGP) Determines the Optimal Path Between Autonomous Systems
The internet relies on the Border Gateway Protocol to stitch together tens of thousands of independent networks into a single global routing table. By evaluating a strict sequence of attributes—from local preference to path length—BGP mathematically guarantees data finds the most efficient route without a centralized authority.
By Tariq Nasser
- Hardware Vendors
- Prioritize proprietary extensions like Weight to give network administrators granular control within a single-vendor ecosystem.
- Open Standards Advocates
- Focus on the universal, vendor-neutral attributes defined in RFC 4271 to ensure interoperability across the global internet.
- Network Engineering Educators
- Emphasize the strict sequence of the decision algorithm as a foundational concept for troubleshooting and traffic engineering.
Perspectives this story doesn't cover
- Cloud Service Providers
- Internet Service Providers (ISPs)
At a glance
- BGP stitches together over 70,000 independent networks into a single global internet.
- The protocol uses a strict 13-step elimination algorithm to select the single best path for data.
- Decisions are driven by corporate policy and economics, not just physical distance.
- Local Preference dictates outbound traffic, while MED and AS Path Prepending influence inbound traffic.
- Arbitrary tiebreakers ensure the algorithm always reaches a definitive conclusion to prevent routing loops.
Why it matters now
Without BGP, the internet would fragment into isolated corporate networks incapable of exchanging traffic. Understanding its path selection algorithm reveals how global connectivity is maintained not by a central governing body, but by a fragile, decentralized consensus among competing telecom providers.
Every time a user requests a web page, their data traverses a fractured landscape of competing corporate networks, arriving in milliseconds because a 35-year-old protocol mathematically negotiated the cheapest, most efficient route. The internet is not a single entity; it is a collection of over 70,000 independent networks, known as Autonomous Systems (AS), operated by telecom providers, tech giants, and universities.[6]
Stitching these competing domains together requires a mechanism that can evaluate millions of potential routes and select exactly one best path for any given destination. That mechanism is the Border Gateway Protocol version 4 (BGP-4), defined by the Internet Engineering Task Force (IETF) in 2006 under RFC 4271.[1]
As the IETF specification states, "BGP is an inter-Autonomous System routing protocol," designed to "exchange network reachability information with other BGP systems." This reachability information includes a list of AS numbers that routing information has traversed, preventing loops and enabling policy-based routing across the globe.[1]
Unlike interior routing protocols that simply seek the shortest physical path in milliseconds, BGP is fundamentally an instrument of corporate policy and economics. Network operators configure BGP over TCP port 179 to prefer routes that cost less money, honor peering agreements, or avoid specific geographic regions, making the optimal path a business decision rather than a purely technical one.[4][6]
To enforce these policies, BGP relies on a deterministic, 13-step path selection algorithm. When a router receives multiple routes to the same destination, it does not average them or load-balance by default; it eliminates candidates one by one until a single winner remains.[2][5]
The decision process often begins with the highest Weight, a proprietary attribute injected by hardware vendors. As Cisco's documentation notes, "Weight is a Cisco-defined attribute that is local to a router." It is not transmitted to other routers, allowing an administrator to force traffic down a specific link regardless of what the rest of the network advertises.[2]
The decision process often begins with the highest Weight, a proprietary attribute injected by hardware vendors.
If Weight is equal or unsupported—as is the case on non-Cisco hardware like HPE Aruba switches—the algorithm evaluates Local Preference. This is the primary tool for outbound traffic engineering within an Autonomous System. A route with a Local Preference of 200 will always beat a route with 100, allowing an AS to prioritize a paid transit link over a congested free peering connection.[3][4]
Only if Local Preference is tied does BGP look at the AS_PATH length. This is the closest BGP gets to a traditional distance metric. The protocol counts the number of distinct networks a route passes through; a path traversing three networks is preferred over one traversing four.[1][5]
However, the AS_PATH is easily manipulated. Network engineers frequently use a technique called "AS path prepending," artificially lengthening their own path by repeating their AS number up to 10 times to discourage inbound traffic from using a specific 10-gigabit or 100-gigabit link.[4][6]
If the path lengths are identical, the router examines the Origin attribute, preferring routes generated internally over those learned via older protocols or redistributed from other sources. This step ensures that native network routes take precedence over imported ones.[1][5]
The next major tiebreaker is the Multi-Exit Discriminator (MED). While Local Preference controls outbound traffic, MED attempts to influence inbound traffic from a directly connected neighbor. A lower MED value is preferred, signaling to the neighboring AS which of several redundant links it should use.[1][4]
As the Study CCNP curriculum published in February 2024 explains, "The BGP path selection algorithm is a complex process that evaluates multiple attributes in a specific order." If MED fails to break the tie, the router prefers External BGP (eBGP) paths over Internal BGP (iBGP) paths, pushing traffic out of the local network as quickly as possible.[5]
Finally, if all policy and distance metrics are identical, the protocol resorts to arbitrary tiebreakers: the lowest interior gateway protocol (IGP) metric to the BGP next hop, the lowest BGP router ID, and finally, the lowest neighbor IP address. These final steps ensure the algorithm always reaches a definitive conclusion.[2][5]
The resilience of this strict elimination sequence is the reason the internet functions at its current scale. Despite the lack of a central authority, BGP's decentralized decision-making allows competing entities to route terabytes of data per second while strictly enforcing their own commercial interests.[6]
Terms to know
- BGP (Border Gateway Protocol)
- The core routing protocol of the internet that makes routing decisions based on paths, network policies, or rule-sets configured by a network administrator.
- Local Preference
- A BGP attribute used to tell routers within the same Autonomous System which outbound path is preferred for a specific destination.
- AS_PATH
- A list of the Autonomous System numbers that a route has traversed, used by BGP to prevent loops and determine the shortest network path.
- MED (Multi-Exit Discriminator)
- An attribute used to suggest to an external neighboring Autonomous System which of several redundant links it should use to send traffic inward.
Questions readers ask
What is an Autonomous System (AS)?
An Autonomous System is a large network or group of networks that has a unified routing policy. Every major ISP, tech company, and large university operates as its own AS.
Why does BGP use policies instead of just the shortest path?
Because the internet is made of competing businesses. BGP allows a network to route traffic based on financial agreements, choosing a longer path that is free over a shorter path that costs money.
What happens if two routes have the exact same attributes?
BGP uses arbitrary tiebreakers, such as selecting the route from the router with the lowest IP address, to ensure a single path is always chosen and routing loops are prevented.
Sources
[1]IETFOpen Standards AdvocatesA Border Gateway Protocol 4 (BGP-4)
Read on IETF →
[2]CiscoHardware VendorsBGP best path algorithm
Read on Cisco →
[3]HPE Aruba NetworkingHardware VendorsIntroduction
Read on HPE Aruba Networking →
[4]NetAcad at FITNetwork Engineering EducatorsChapter 13: BGP Path Selection
Read on NetAcad at FIT →
[5]Study CCNPNetwork Engineering EducatorsBGP Path Selection Algorithm Explained
Read on Study CCNP →
[6]Factlen Editorial TeamNetwork Engineering EducatorsSynthesis by Factlen editorial team
Read on Factlen Editorial Team →
Comments
More in Content Types
See all →Lie Detection Science
How the Polygraph Actually Measures Physiological Arousal Instead of Deception
6 sources
Cryptographic Standards
Evaluating Cryptographic Efficiency: Why a 256-Bit Symmetric Key Matches a 15360-Bit RSA Key
6 sources
Risk Management
Calculating the Optimal Allocation: How the Kelly Criterion Balances Edge Against Volatility Drag
9 sources
Global AI Economy
How AI's Economic Impact Splits the World: Job Destruction in the US vs. Growth Engine in Developing Nations
4 sources
Every angle. Every day.
Get Content Types stories with full source coverage and perspective breakdowns delivered to your inbox.




