
What is BGP? BGP (Border Gateway Protocol) is the routing protocol that connects the separate networks that make up the internet. Each network, such as an ISP, a cloud provider or a large company, uses BGP to tell its neighbors which IP addresses it can reach, and every BGP router uses those announcements to pick a path for traffic. In networking terms, BGP is the internet's map-maker: it doesn't carry your data, it decides which way your data goes.
The Border Gateway Protocol (BGP) is one of the most critical—and least understood—components of the global internet. Invented in 1989, BGP has quietly powered the interconnection of networks for more than three decades. From loading a webpage to streaming video or sending an email, your data likely travels across paths negotiated by BGP. But what exactly is BGP? How does it work, where is it used, and why is it still relevant today?
Let’s break down the history and fundamentals of BGP to answer the most common questions about this essential protocol.
What is the BGP Protocol?
BGP, short for Border Gateway Protocol, is a standardized exterior gateway protocol that enables data routing between autonomous systems (AS) on the internet. An autonomous system is essentially a large network or group of networks under a single administrative domain—like an internet service provider (ISP), cloud provider, or large enterprise.
BGP is defined in RFC 4271 and is classified as a path vector protocol. Unlike interior routing protocols such as OSPF or EIGRP that operate within a single organization, BGP is designed to connect networks across administrative boundaries. It governs how packets find their way across the vast, decentralized internet.
How Does BGP Work?
At its core, BGP works by exchanging routing and reachability information between routers. Each BGP-enabled router communicates with peers (other BGP routers) to advertise the networks it can reach. These “advertisements” contain path information, including the list of ASes that the data must traverse to reach a destination.
Here’s a simplified breakdown of how BGP works:
- Peer Establishment: Two routers (often at the edge of different networks) form a BGP session using TCP (port 179).
- Route Advertisement: Each router advertises known IP prefixes (destination networks) and the path to reach them.
- Route Selection: Routers use a set of attributes—like AS path length, local preference, and MED (Multi-Exit Discriminator)—to choose the best route.
- Routing Decisions: The router installs the best path in its routing table and forwards packets accordingly.
One key characteristic of BGP is that it doesn’t use metrics like bandwidth or latency to choose routes. Instead, it prioritizes policy and path control, giving administrators fine-grained control over routing decisions.
BGP Routing: How a BGP Router Picks a Path
A BGP router (or BGP speaker) often learns several paths to the same destination prefix, one from each peer. It keeps them all and installs one as the best path. The comparison runs in a fixed order and stops at the first attribute that differs. The common steps are:
- Highest weight (a Cisco-specific, router-local setting).
- Highest local preference, the main tool for choosing an exit from your own network.
- Routes the router originated itself win over learned ones.
- Shortest AS path: fewer autonomous systems to cross.
- Lowest origin type (IGP before EGP before incomplete).
- Lowest MED, a neighbor's hint about which of its entry points to use.
- eBGP over iBGP routes.
- Lowest IGP cost to the next hop, then tie-breakers such as the oldest route and lowest router ID.
Because operators set local preference, MED and AS-path prepending by policy, BGP routing reflects business agreements as much as network topology. That's also why two packets to the same place can take very different paths.
Where is BGP Used?
BGP is primarily used between different networks—most notably between ISPs, cloud providers, content delivery networks, and enterprise networks. This is known as External BGP (eBGP).
However, BGP is also used within large organizations that need scalable internal routing across multiple sites or data centers. This is called Internal BGP (iBGP).
In short, eBGP runs between different autonomous systems and iBGP runs between routers inside the same one, carrying the routes eBGP learned to every edge of the network.
Common use cases for BGP include:
- Connecting a company’s on-prem data center to AWS, Azure, or GCP.
- Routing traffic between different ISPs (multihoming).
- Advertising a cloud provider’s or CDN’s global IP routes.
- Load balancing internet traffic across redundant network connections.
BGP vs OSPF
OSPF (Open Shortest Path First) is an interior routing protocol: it runs inside one organization's network and picks routes by link cost, converging quickly when a link fails. BGP is the exterior protocol between organizations and picks routes by policy. Most large networks run both, OSPF (or IS-IS) inside and BGP at the edges. For a side-by-side comparison, and how noBGP fits next to them, see BGP vs OSPF vs noBGP.
BGP Operates at Which Layer?
BGP is considered an Application Layer protocol (Layer 7) in the OSI model, but it runs on top of the Transport Layer (Layer 4) using TCP. While it facilitates network communication, it isn’t responsible for moving the data packets themselves—that’s handled by lower-layer protocols like IP.
This distinction is important: BGP doesn’t carry user traffic, but instead manages the control plane, telling routers where to send that traffic.
Who Invented BGP?
BGP was co-developed by Yakov Rekhter at IBM and Kirk Lougheed at Cisco in 1989. It was designed as a rapid replacement for the now-defunct EGP (Exterior Gateway Protocol), which had become inadequate as the internet began growing beyond its academic roots.
Their work was formalized in RFC 1105, the original specification for BGP. Since then, the protocol has evolved through multiple versions, but the core concept has remained surprisingly consistent.
Why is BGP Still Used?
Despite being over 30 years old, BGP remains the de facto routing protocol of the internet. Its longevity is due to a few key factors:
- Scalability: BGP can handle the massive size and complexity of global routing tables.
- Policy Control: Network operators can define routing rules based on business or technical needs.
- Decentralization: BGP supports a distributed model, allowing independent network operators to collaborate without central control.
- Stability: BGP changes routes conservatively, minimizing route flapping and instability.
However, BGP is not without flaws. It lacks built-in authentication, doesn’t validate route ownership, and can result in non-deterministic routing paths. These limitations have led to route hijacking incidents and misconfigurations that have taken major services offline. Read more about BGP security vulnerabilities and BGP alternatives for the cloud era.
Conclusion
BGP may be an aging protocol, but it remains a vital piece of internet infrastructure. If you’ve ever wondered how your data knows where to go, the answer often lies in a BGP decision made by a router somewhere in the world. While there is growing discussion about alternatives or upgrades (like RPKI or BGPsec), the fundamental design of BGP still governs the modern internet.
Understanding BGP is more than just an academic exercise—it’s a look behind the curtain of the world’s largest and most complex network.