What is BGP? The Internet's Routing Protocol Explained
The Border Gateway Protocol, or BGP, is the routing protocol that holds the internet together. Every time you load a webpage, send an email, or stream a video, BGP is working behind the scenes to figure out how your data should travel across dozens of independent networks to reach its destination.
How the Internet is Organized
The internet is not a single network — it is a network of networks. Thousands of organizations, from large ISPs like AT&T and Deutsche Telekom to cloud providers like Amazon (AS16509) and Google (AS15169), each operate their own independent network. These individual networks are called Autonomous Systems (ASes), and each one is identified by a unique number called an ASN.
BGP is the protocol these autonomous systems use to exchange routing information with each other. It tells each network: "I can reach these IP address ranges, and here is the path to get there."
How BGP Works
BGP is a path vector protocol. When a network wants to announce that it owns a block of IP addresses (called a prefix), it sends a BGP announcement to its neighbors. Each neighbor that accepts the announcement prepends its own AS number to the AS path and forwards it to its neighbors, and so on.
For example, when Google announces the prefix 8.8.8.0/24 (which contains their famous 8.8.8.8 DNS server), the announcement might travel through several networks:
- Google (AS15169) originates the announcement
- A transit provider like NTT (AS2914) receives it and adds its ASN to the path
- Other networks receive it from NTT with the path "2914 15169"
Each router along the way uses the AS path (among other attributes) to decide the best route to reach that prefix. Generally, shorter AS paths are preferred, but network operators can apply complex routing policies to influence path selection.
BGP Sessions and Peering
BGP routers establish sessions with each other over TCP (port 179). There are two types of BGP sessions:
- eBGP (External BGP) — sessions between routers in different autonomous systems. This is how networks exchange routes with each other.
- iBGP (Internal BGP) — sessions between routers within the same autonomous system. This distributes external routing information internally.
Networks connect to each other through peering (direct interconnection, often at Internet Exchange Points) or by purchasing transit from a larger provider. You can explore these relationships by looking up any ASN — for example, Cloudflare (AS13335) shows its upstream and downstream neighbors.
Why BGP Matters
BGP is often called the "postal system of the internet." Without it, your ISP would have no idea how to reach servers hosted on other networks. But BGP's design also makes it fragile in some ways:
- BGP hijacks — A network can accidentally (or maliciously) announce prefixes it doesn't own, redirecting traffic meant for someone else.
- Route leaks — A network can accidentally propagate routes it shouldn't, causing traffic to take suboptimal or unintended paths.
- Convergence delays — When a route changes, it can take minutes for all networks on the internet to learn about the update.
These issues have caused notable outages. In 2021, Facebook's BGP routes were withdrawn, making the entire platform unreachable for hours. In 2008, Pakistan Telecom accidentally hijacked YouTube's IP space, taking the site offline worldwide.
To address these security concerns, the internet community has developed RPKI (Resource Public Key Infrastructure), which allows networks to cryptographically verify that a BGP announcement is authorized by the legitimate holder of the IP address space.
A Brief History
BGP was first defined in 1989 in RFC 1105. The current version, BGP-4, was standardized in RFC 4271 (2006) and supports Classless Inter-Domain Routing (CIDR), which allows flexible allocation of IP address space. BGP-4 has been the backbone of internet routing for over two decades, handling the growth from a few thousand prefixes to over a million today.
See BGP in Action
You can explore real BGP routing data using a BGP Looking Glass. Try looking up any IP address or ASN to see the live BGP routes, AS paths, and origin information:
- Look up 8.8.8.8 — Google's public DNS
- Look up 1.1.1.1 — Cloudflare's DNS resolver
- Look up AS15169 — Google's autonomous system