Protocols: BGP

The internet feels like a single, seamless entity. You type in a web address, and moments later, a page from a server halfway across the world appears on your screen. But behind this modern marvel lies a complex, decentralized “network of networks,” and the master coordinator of it all is a protocol you’ve likely never heard of: the Border Gateway Protocol (BGP). This foundational protocol is the lifeblood of the global internet, dictating how traffic finds its way across thousands of independent networks to reach its final destination.

The Internet’s Postal Service

Imagine the internet not as one network, but as thousands of individual postal districts, each managed by a different company—an Internet Service Provider (ISP), a large corporation like Google, or a university. These districts are called Autonomous Systems (AS), and each has a unique number, like a zip code, known as an ASN. BGP is the global postal service that ensures a letter (your data packet) dropped in one district can find its way to an address in any other district, no matter how many districts it has to cross.

BGP’s primary job is to exchange “reachability” information. Each AS uses BGP to announce to its neighbors which IP addresses it can deliver traffic to. These announcements don’t just say, “I can reach this address”; they include the full path of AS “districts” the announcement has traversed. This “path-vector” is crucial for two reasons: it prevents announcements from getting stuck in loops, and it allows network administrators to enforce policies on how their traffic flows.

Two Faces of BGP: Managing Traffic Within and Between Networks

BGP operates in two distinct modes, depending on where the conversation is happening:

  • External BGP (eBGP): This is used when different Autonomous Systems exchange routing information. It’s the core function of BGP, stitching the internet together by allowing, for example, your home ISP to learn routes from major content providers.
  • Internal BGP (iBGP): This is used to distribute the external routes learned via eBGP to all the routers within a single AS. This ensures that every router inside the network has a consistent map of the outside world, preventing traffic from hitting a dead end.

To prevent routing loops inside an AS, iBGP has a strict “split-horizon” rule: a route learned from one internal peer cannot be advertised to another. While effective, this rule means that for all routers to be on the same page, they must all connect directly to each other in a “full mesh.” For large networks with thousands of routers, this becomes unmanageable. To solve this, network engineers use solutions like Route Reflectors, specialized routers that can safely “reflect” routes to others, dramatically simplifying the internal network topology.

Making the “Best” Choice: Policy Over Speed

When a BGP router learns multiple ways to reach the same destination, it doesn’t just pick the fastest one. Instead, it follows a strict, multi-step decision process to select a single “best” path based on policy. This process evaluates a series of path attributes in a specific order, stopping as soon as one path is preferred.

Key attributes include:

  • LOCAL_PREF: An internal-only attribute used to choose which exit point your own network prefers. A higher value wins, giving an administrator total control over their outbound traffic.
  • AS_PATH Length: A shorter path (one that crosses fewer Autonomous Systems) is preferred.
  • MED (Multi-Exit Discriminator): A “suggestion” sent to a neighboring AS to influence which link they use to send you traffic. A lower value is preferred, but the neighbor is free to ignore it.

This design reflects the real-world dynamics between networks: you have absolute control over your own domain (LOCAL_PREF) but can only seek to influence others (MED).

A Fragile Foundation: BGP’s Inherent Security Flaws

BGP was designed in a more trusting era of the internet and contains no built-in mechanism to verify that a network is authorized to announce the IP addresses it claims to control. This has led to two major vulnerabilities:

  1. Route Hijacking: A malicious actor can falsely announce that they own a block of IP addresses. A particularly effective method is to announce a more-specific, smaller chunk of a legitimate network’s address space. Because routers always prefer the most specific route, traffic is diverted to the attacker, who can then eavesdrop on or discard the data.
  2. Route Leaks: These are typically unintentional but can be just as damaging. A common example is when a customer network mistakenly re-advertises the routes it learned from one ISP to its other ISP. This can cause a massive amount of internet traffic to suddenly try to flow through a small network not equipped to handle it, leading to widespread congestion and outages.

The most famous example of BGP’s vulnerability was the 2008 YouTube hijacking. To block YouTube domestically, Pakistan Telecom created an internal, more-specific route for YouTube’s IP addresses. This route was accidentally leaked to its global internet provider and propagated across the world. Because this leaked route was more specific, routers everywhere chose it as the best path, sending traffic destined for YouTube into a black hole in Pakistan. The incident made YouTube inaccessible for much of the world for several hours.

Securing the Internet’s Roadmap

To combat these vulnerabilities, the engineering community developed the Resource Public Key Infrastructure (RPKI). RPKI provides a way to cryptographically verify that an AS is the legitimate originator of an IP address prefix.

Here’s how it works:

  • IP address owners create a cryptographically signed object called a Route Origin Authorization (ROA), which binds their IP prefixes to their ASN.
  • Network operators perform Route Origin Validation (ROV), downloading all the valid ROAs and using them to check the BGP announcements they receive.
  • Announcements are sorted into three categories: Valid (the AS and prefix match a ROA), Invalid (the announcement violates a ROA), and NotFound (there’s no ROA for this prefix).

The global best practice is to accept Valid and NotFound routes but to drop any route that is Invalid. This directly prevents hijacking attempts. As of early 2025, over half of all internet routes have valid ROAs, and this number is steadily growing, making the entire ecosystem more secure.

The story of BGP is the story of the internet itself—a decentralized, evolving system built on trust and adapted for a world where that trust is no longer guaranteed. Its continued stability relies on a collective, global effort by network operators to implement security best practices and ensure the internet’s core routing system remains reliable for everyone.

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Journey Blog by Crimson Themes.