Routing Protocols
Navigating the Internet's Highways
The internet is not a single entity; it is an "inter-network" of thousands of distinct, autonomous networks owned by ISPs, telecom giants, and large corporations.
When you send a packet from your laptop in New York to a server in Tokyo, it jumps across 15 to 20 different routers. Routing is the mechanism by which these routers dynamically figure out the fastest, most efficient path to the destination.
The Routing Table
Every router maintains a Routing Table—a map of network destinations and the "next hop" IP address required to get there. If a router receives a packet destined for 104.21.5.0/24 and doesn't know the exact path, it forwards it to its "Default Gateway" (a bigger router upstream).
Every router entry uses longest prefix match: if a packet matches both 10.0.0.0/8 and 10.0.1.0/24, the more specific /24 wins. This lets networks advertise broad defaults while keeping precise overrides for special cases.
Dynamic Routing Protocols
Manually updating routing tables across the globe is impossible. Routers use protocols to constantly talk to each other, updating their maps when cables are cut or new lines are laid. These protocols fall into two main categories:
1. Interior Gateway Protocols (IGP) - Routing inside a company Used entirely within a single autonomous network (like a university campus or an enterprise datacenter). - OSPF (Open Shortest Path First): A Link-State protocol. Every router maps out the entire topology of the network. It calculates the absolute fastest path using Dijkstra's algorithm based on bandwidth (a 10Gbps fiber link costs less to traverse than a 100Mbps copper link). - RIP (Routing Information Protocol): A legacy Distance-Vector protocol. It only cares about "hop count" (how many routers are in the way). A path with 2 slow routers is preferred over a path with 3 incredibly fast routers. Rarely used today. - IS-IS: A link-state protocol closely related to OSPF, common in very large ISP backbones because it scales well and is protocol-agnostic.
2. Exterior Gateway Protocols (EGP) - Routing the Global Internet Used to connect entirely different autonomous organizations (ASNs) together. - BGP (Border Gateway Protocol): The protocol that literally holds the global internet together. BGP does not care about bandwidth or link speed. It makes routing decisions based on Paths, Policies, and Rules negotiated between massive ISPs. - Example: "Route traffic through AT&T instead of Verizon because our peering contract with AT&T is cheaper." - The BGP Vulnerability: BGP relies on absolute trust. If a rogue ISP accidentally (or maliciously) advertises that they are the fastest route to YouTube's IP block, a massive portion of global traffic will route to them, causing a catastrophic outage (a BGP Hijack). This happens several times a year.
Autonomous Systems
An Autonomous System (AS) is a network under a single administrative authority, identified by an AS number (ASN). Your ISP has an ASN; Google has an ASN; Cloudflare has an ASN. BGP exchanges reachability between ASNs. Tools like whois and BGP Looking Glasses let you see which ASN owns a given IP block—and which BGP paths reach it from around the world.
Route Preference and Metrics
When a router has multiple valid paths, it picks by preference: longest prefix first, then administrative distance (trust level of the source protocol), then the protocol-specific metric (cost, hop count, bandwidth). You can influence routing with administrative distance and priority values, which is how engineers force traffic through preferred links.
Equivalent Multipath and Failover
Production networks rarely rely on a single path. ECMP (Equal-Cost Multi-Path) hashes flows across several equal-cost links to use all the available bandwidth, while BFD (Bidirectional Forwarding Detection) quickly detects a failed link so routing converges in milliseconds rather than seconds. The design goal is that no single cable, router, or ISP link outage is visible to users.