Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
Module 11: Routing Deep Dive
Routing is how packets find their way from source to destination across interconnected networks. This module takes you from basic routing concepts to understanding how the entire internet’s routing works.Estimated Time: 4-5 hours
Difficulty: Intermediate to Advanced
Prerequisites: Module 9 (IP Addressing), Module 10 (NAT)
Difficulty: Intermediate to Advanced
Prerequisites: Module 9 (IP Addressing), Module 10 (NAT)
11.1 What is Routing?
Routing is the process of selecting a path for traffic across one or more networks. It is the GPS navigation system of the internet — given a destination, figure out the best next turn to take.The Fundamental Question
When a packet arrives at a router, the router asks:“Where should I send this packet next to get it closer to its destination?”A router does not know the full path to the destination. It only knows the next hop — the next router to forward the packet to. Each router along the way makes the same decision independently, like passing a baton in a relay race. The packet makes its way across the internet hop by hop, with each router consulting its own routing table. Think of it like asking for directions in a foreign city. You ask someone “How do I get to the train station?” They do not give you the entire route — they say “go two blocks north and ask again.” The next person says “turn left and ask the person at the corner.” Each person only knows the next step, but following their advice gets you there. That is routing.
Routers vs Switches
| Device | Layer | Uses | Connects |
|---|---|---|---|
| Switch | Layer 2 | MAC addresses | Devices in same network |
| Router | Layer 3 | IP addresses | Different networks |
11.2 The Routing Table
Every router (and every computer!) has a routing table - a set of rules determining where to send packets.Viewing Your Routing Table
- Windows
- Linux/Mac
Sample Routing Table
How Routing Decisions Work
When a packet needs to be sent:Find Matching Routes
Multiple routes may match (e.g., 10.0.0.0/8 and 10.1.0.0/16 both match 10.1.1.1).
11.3 Default Gateway
The default gateway is the “route of last resort” - where packets go when no specific route matches.Your Home Network
11.4 Static vs Dynamic Routing
Static Routing
Routes are manually configured by an administrator.- Simple, predictable
- No routing protocol overhead
- Full control
- Doesn’t scale (imagine configuring 1000 routes manually)
- No automatic failover
- High maintenance
- Small networks
- Stub networks (single exit point)
- Specific traffic engineering
Dynamic Routing
Routers automatically discover routes and share information using routing protocols.- Automatic failover
- Scales to massive networks
- Self-healing
- More complex
- Convergence time
- Protocol overhead
11.5 Interior vs Exterior Gateway Protocols
The internet is divided into Autonomous Systems (AS) - networks under single administrative control.| Type | Protocols | Use Case |
|---|---|---|
| IGP (Interior Gateway Protocol) | OSPF, EIGRP, RIP, IS-IS | Within an organization |
| EGP (Exterior Gateway Protocol) | BGP | Between organizations, internet backbone |
11.6 OSPF (Open Shortest Path First)
OSPF is the most common IGP in enterprise networks. Think of it as routers building a shared map of the entire network and then each independently calculating the shortest path to every destination using that map.How OSPF Works
- Neighbor Discovery: Routers find each other using Hello packets (sent every 10 seconds on broadcast networks). If a router stops hearing Hellos from a neighbor for 40 seconds, it declares the neighbor dead and recalculates routes. This is like coworkers checking in with each other — “Are you still here? Good.” If someone stops responding for too long, the team reorganizes without them.
- Database Synchronization: Routers share their view of the network using Link-State Advertisements (LSAs). Each router describes its directly connected links and costs. All routers build an identical Link-State Database (LSDB) — a complete map of the network.
- SPF Calculation: Each router runs Dijkstra’s shortest-path-first algorithm on the LSDB to compute the shortest path to every destination. This is computationally expensive, which is why large networks are divided into areas.
- Routing Table: The results of the SPF calculation populate the routing table with optimal next-hop entries.
OSPF Areas
Large networks are divided into areas to reduce complexity:OSPF Metrics
OSPF uses cost as its metric, based on bandwidth:11.7 BGP (Border Gateway Protocol)
BGP is the routing protocol of the internet. Every ISP, cloud provider, and major network uses BGP. If OSPF is how traffic moves within a single company’s network, BGP is how companies tell each other which IP ranges they own and how to reach them. The global internet routing table has over 900,000 entries, and BGP manages all of them.BGP Basics
- Path Vector Protocol: Unlike OSPF (which shares individual link states), BGP routes include the full AS path — the complete list of organizations the traffic must traverse. This allows each network to make policy decisions like “avoid routing through AS64500 because they are a competitor.”
- AS Numbers: Every organization running BGP has a unique ASN (Autonomous System Number). Google is AS15169, Cloudflare is AS13335, Amazon is AS16509. You can look up any ASN at
bgp.he.net. - Peering: Organizations agree to exchange routes. This can be settlement-free peering (we both benefit, no money changes hands) or transit (you pay me to carry your traffic to the rest of the internet).
BGP in Action
Why BGP Matters
Multi-homing
Connect to multiple ISPs for redundancy. BGP handles failover.
Traffic Engineering
Control which path traffic takes (incoming and outgoing).
IP Announcements
Tell the internet “this IP range belongs to me.”
Internet Stability
BGP misconfiguration can (and has) broken the internet.
BGP Hijacking
What a BGP hijack looks like at the packet level
11.8 Route Summarization (Aggregation)
Instead of advertising many specific routes, advertise one summary:- Smaller routing tables
- Faster convergence
- Less memory/CPU usage
11.9 Routing in the Cloud (AWS VPC Example)
Cloud networks use routing tables extensively:VPC Route Table Structure
Route Table Entries Explained
| Destination | Target | Meaning |
|---|---|---|
| 10.0.0.0/16 | local | Traffic within VPC, route locally |
| 0.0.0.0/0 | igw-xxx | Default route to Internet Gateway |
| 0.0.0.0/0 | nat-xxx | Default route to NAT Gateway |
| 172.16.0.0/12 | pcx-xxx | Route to VPC Peering Connection |
| 192.168.0.0/16 | vgw-xxx | Route to VPN Gateway (on-prem) |
11.10 Traceroute: See Routing in Action
Traceroute shows the path packets take:How Traceroute Works
Uses TTL (Time To Live) manipulation:- Send packet with TTL=1 → First router decrements to 0, sends back “Time Exceeded”
- Send packet with TTL=2 → Second router decrements to 0, sends back error
- Continue until destination reached
11.11 Common Routing Problems
1. Routing Loops
- TTL (limits hops)
- Split Horizon (don’t advertise routes back where you learned them)
- Route Poisoning
2. Black Holes
Route exists but destination is unreachable:3. Asymmetric Routing
11.12 Key Takeaways
Longest Prefix Wins
More specific routes (longer prefix) always take precedence.
Default Gateway
0.0.0.0/0 is the catch-all route for unknown destinations.
BGP Runs the Internet
Every major network exchange uses BGP to share routes.
Cloud = Software Routing
VPC route tables are just software-defined routing.
Next Module
Module 12: DNS Deep Dive
Master the Domain Name System - the phonebook of the internet.
Interview Deep-Dive
What is BGP and why is it considered the most critical routing protocol on the internet?
What is BGP and why is it considered the most critical routing protocol on the internet?
Strong Answer:
- BGP connects autonomous systems — the independently operated networks that make up the internet. Every route between ISPs, cloud providers, and enterprises is exchanged via BGP. The global routing table has over 900,000 entries, all managed by BGP.
- BGP is a path vector protocol. Routes carry the full AS path, enabling policy-based routing: prefer a free peering partner over paid transit, avoid a competitor’s network, prefer geographically closer paths.
- BGP is critical because misconfiguration has global impact. The 2008 Pakistan/YouTube incident, the 2021 Facebook outage (BGP withdrawals made DNS unreachable), and regular smaller incidents demonstrate BGP can break large internet segments in minutes.
- In cloud architecture, BGP is used for AWS Direct Connect, VPN connections, and Transit Gateway routing.
What is asymmetric routing and why does it cause problems with stateful firewalls?
What is asymmetric routing and why does it cause problems with stateful firewalls?
Strong Answer:
- Asymmetric routing means the forward path (A to B) differs from the return path (B to A). On the internet this is common and usually harmless.
- The problem arises with stateful firewalls that track connection state. The firewall creates an entry when it sees the outbound SYN on path A-B-C. When SYN-ACK returns via D-E-A (bypassing the firewall), there is no matching record and the packet is dropped.
- In cloud environments this manifests as: multi-AZ traffic entering through one AZ’s LB but exiting through another AZ’s NAT Gateway, Transit Gateway routing divergence, and VPN configurations with different tunnels per direction.
- To diagnose: traceroute from both ends and compare paths. Solutions include ensuring symmetric paths through the same firewall, disabling state tracking for specific flows, or using firewall clustering with shared state.
Compare OSPF and BGP. When would you use each, and do they work together?
Compare OSPF and BGP. When would you use each, and do they work together?
Strong Answer:
- OSPF is an IGP for internal routing. It is link-state: every router builds a complete topology map and runs Dijkstra’s algorithm for shortest paths. Converges in seconds. Selects routes by cost (bandwidth-based).
- BGP is an EGP for inter-organization routing. It is path-vector: routes carry full AS paths. Selects routes by policy (business relationships, path length). Converges slowly by design to avoid global instability.
- They commonly work together. OSPF handles fast internal routing; BGP handles border routing with external networks. BGP-learned external routes can be redistributed into OSPF so internal routers know how to reach them. Internal OSPF routes are summarized and advertised via BGP to peers.
- In AWS, BGP handles Direct Connect and VPN route exchange. Internal VPC routing is AWS’s SDN, not OSPF or BGP.