What Is BGP?
How BGP routes traffic between autonomous systems to make the internet work.
What Is BGP?
BGP (Border Gateway Protocol) is the routing protocol that makes the internet work. It's responsible for exchanging routing information between autonomous systems (AS) — independently managed networks like ISPs, cloud providers, and large enterprises.
BGP is often called the "postal system of the internet." Just as the postal system routes letters between countries, BGP routes data packets between networks.
Autonomous Systems
An Autonomous System (AS) is a network or group of networks under a single administrative control, identified by a unique ASN (Autonomous System Number).
Examples: - AS15169 — Google - AS13335 — Cloudflare - AS16509 — Amazon (AWS)
How BGP Works
BGP routers (peers) exchange information about which IP prefixes (address blocks) they can reach. Each route includes the full AS path — the sequence of autonomous systems a packet would traverse.
Prefix: 8.8.8.0/24
AS Path: 64500 → 3356 → 15169
(Your ISP → Level3 → Google)
Path Selection
When BGP knows multiple paths to the same destination, it selects the best one based on a series of criteria (in order):
- Highest Local Preference — Manually configured by the network admin
- Shortest AS Path — Fewer networks to traverse
- Lowest Origin Type — IGP > EGP > Incomplete
- Lowest MED — Multi-Exit Discriminator (hint from neighbor)
- eBGP over iBGP — Prefer external routes
- Lowest Router ID — Tiebreaker
eBGP vs iBGP
- eBGP (External BGP) — Between routers in different autonomous systems
- iBGP (Internal BGP) — Between routers in the same autonomous system
eBGP peers are typically directly connected, while iBGP peers can be anywhere in the same AS.
Why BGP Matters
- The global BGP routing table contains over 1 million prefixes
- BGP misconfigurations have caused major internet outages (Facebook 2021, Pakistan/YouTube 2008)
- BGP is inherently trust-based — routers believe what their peers announce
- RPKI (Resource Public Key Infrastructure) adds cryptographic verification to BGP announcements