BGP (Border Gateway Protocol) is the routing system that lets the thousands of independent networks that make up the internet share directions on how to reach each other. When you load a website hosted in another country, BGP is what tells your traffic which chain of networks to hop through to get there. In short, BGP routing is the internet's master map, constantly updated by every major network so packets always find a working path to their destination.
Content Table
What BGP Actually Is
The internet is not one network. It is more than 70,000 separate networks run by internet providers, cloud platforms, universities, governments, and big companies. Each one manages its own slice of the internet. BGP is the protocol these networks use to tell each other, "Here are the IP addresses I can reach, and here's the path to get to them."
Think of it like a global postal system where each regional post office announces which zip codes it can deliver to. When a letter needs to travel from one region to another, each office passes it along based on those announcements. BGP does the same thing with data, except the announcements update in seconds and cover billions of IP addresses.
Autonomous Systems and How They Talk
Every network that participates in BGP is called an Autonomous System (AS). Each AS gets a unique number, called an ASN, so it can be identified across the internet. Google's main network, for example, uses AS15169. Cloudflare uses AS13335.
Autonomous system routing works through two flavors of BGP:
- eBGP (external BGP): used between two different autonomous systems, like your ISP peering with a backbone provider.
- iBGP (internal BGP): used inside a single autonomous system to share what it learned from the outside world across its own routers.
When two networks agree to exchange traffic, they set up a BGP session over a TCP connection (port 179). Once connected, they swap route announcements and keep each other updated whenever a path appears or disappears. You can look up which AS owns a given IP with an ASN lookup tool.
How BGP Picks a Route
Often there are several ways to reach the same destination. BGP does not automatically pick the fastest or shortest physical route. Instead it follows a decision process based on rules and business relationships. The most important factors, roughly in order:
| Attribute | What it does |
|---|---|
| Local Preference | Lets a network prefer certain exit paths, usually the cheapest or a partner link. |
| AS Path Length | Prefers routes that cross fewer autonomous systems, a rough proxy for shorter. |
| MED | A hint from a neighbor about which entry point into their network to prefer. |
| Route Origin | Favors routes learned in more trusted ways. |
Because business relationships often win over raw distance, your traffic can take a longer physical route just because it is cheaper for your ISP. That is one reason a traceroute can reveal a surprising path to a nearby server. If you want to measure the round-trip delay along that path, our ping tool helps put those numbers in context.
The Internet Routing Table
Every BGP router keeps an internet routing table, a giant list of every reachable IP prefix and the best path to each one. This table is enormous and keeps growing. As of recent years, the global IPv4 routing table holds well over 900,000 prefixes, with IPv6 adding hundreds of thousands more.
That size matters. Back in 2014, many older routers hit a hard limit of 512,000 routes in their memory, causing widespread outages when the table crossed that threshold. Router makers now ship hardware sized for a table that will keep expanding for years.
BGP Hijacking and Security
BGP was designed in an era of trust. It largely assumes that when a network announces "I can reach these addresses," it is telling the truth. That trust is the root of BGP hijacking, where a network announces IP prefixes it does not actually own, pulling traffic toward itself.
Real incidents show the damage:
- 2008 YouTube outage: Pakistan Telecom announced a YouTube prefix to block the site locally, and the announcement leaked worldwide, taking YouTube offline for hours.
- 2018 Amazon Route 53 hijack: attackers rerouted DNS traffic to steal cryptocurrency by redirecting users to a fake site.
The main defenses today:
- RPKI (Resource Public Key Infrastructure): cryptographically ties IP prefixes to the AS allowed to announce them, so routers can reject fake announcements.
- Route filtering: networks only accept announcements they expect from a given peer.
- MANRS: an industry initiative encouraging providers to adopt safer routing practices.
You can read more about the RPKI effort through the RIPE NCC's RPKI resources.
Why BGP Matters to You
You never configure BGP yourself unless you run a large network, but its behavior shapes your daily experience:
- Outages: many large internet outages trace back to a BGP misconfiguration, not a cable cut. A famous 2021 Facebook outage started when a BGP change made its servers unreachable.
- Latency: the path BGP chooses affects how far your data travels and how quickly it responds.
- Reachability: if your provider's routes vanish from the global table, sites simply cannot find you.
BGP is the quiet layer that keeps traffic flowing between networks that have never met and do not fully trust each other. When it works, you never notice it. When it breaks, large parts of the internet can vanish in seconds.
See Which Autonomous System Owns an IP
Curious which network handles your BGP routing? Our free ASN lookup reveals the autonomous system behind any IP address, the network name, and its routing details in seconds.
Run an ASN Lookup →
BGP is the only protocol used for routing between separate networks (autonomous systems) across the public internet. Inside a single network, providers use interior protocols like OSPF or IS-IS. But when traffic leaves one network for another, BGP handles the handoff.
New route announcements can spread across the global internet within seconds to a few minutes. That speed is why a single bad announcement can cause a fast, wide outage, and also why fixes can propagate quickly once the correct routes are re-announced.
An Autonomous System (AS) is an actual network with its own routing policy, like an ISP or a cloud provider. An ASN (Autonomous System Number) is the unique identifier assigned to that network so other networks can reference it in BGP announcements, such as AS13335 for Cloudflare.
Not fully yet, but adoption of RPKI and route filtering has sharply reduced accidental and malicious hijacks. As more networks sign and validate their routes, fake announcements get rejected before they spread. Complete protection depends on nearly all networks adopting these practices.
BGP often picks paths based on cost and business agreements rather than the shortest physical distance. Your provider may route traffic through a cheaper partner network even if a more direct link exists, which is why a traceroute can show unexpected detours to nearby servers.
