IP Routing and Forwarding

Graduate Depth 50 in the knowledge graph I know this Set as goal
Unlocks 45 downstream topics
routing forwarding routing-table hop

Core Idea

IP routing is the process by which routers forward packets toward their destination based on routing tables that map destination IP prefixes to outgoing interfaces and next-hop addresses. Routers use longest-prefix-match lookup to select the most specific matching route, enabling hierarchical routing and Internet scalability.

How It's Best Learned

Examine routing tables using `route -n` (Linux) or `route print` (Windows); trace packet routes with `traceroute` to visualize multi-hop paths.

Common Misconceptions

Explainer

From your knowledge of IPv4 addressing and subnetting with CIDR notation, you understand that IP addresses are structured hierarchically and that networks are identified by prefixes of varying length. IP routing is the mechanism that uses this hierarchical structure to forward packets across interconnected networks from source to destination. Every router along the path makes an independent forwarding decision based on its own local routing table — no single device knows or controls the entire path.

A routing table is essentially a lookup table mapping destination IP prefixes to next-hop addresses and outgoing interfaces. When a packet arrives at a router, the router examines the destination IP address in the packet header and searches its routing table for matching entries. The critical rule is longest-prefix match: if the destination 192.168.5.42 matches both 192.168.0.0/16 (a broad match) and 192.168.5.0/24 (a more specific match), the router uses the /24 entry because it has the longer prefix and therefore provides more specific routing information. This is what makes Internet routing scalable — routers do not need an entry for every individual IP address. They can aggregate millions of addresses into a single prefix and only maintain specific entries where finer-grained routing is needed.

The forwarding process at each router is purely local and hop-by-hop. A router does not compute or store the complete path to the destination. It simply determines the best next hop — the neighboring router (or the destination itself, if directly connected) — and forwards the packet to that neighbor. That neighbor then repeats the same process using its own routing table. The packet hops from router to router until it reaches a router that is directly connected to the destination's subnet. This is analogous to asking for driving directions at each intersection rather than planning the entire route upfront. Each router only needs to know the best direction to send traffic for each destination prefix.

Routing tables are populated through two mechanisms. Static routes are manually configured by network administrators and are appropriate for simple, stable topologies. Dynamic routing protocols (like OSPF, BGP, and RIP) allow routers to exchange information about which networks they can reach, automatically building and updating routing tables as the network topology changes. When a link fails, dynamic routing protocols detect the change and recalculate paths, enabling the network to route around the failure. A special entry called the default route (0.0.0.0/0) matches any destination that does not have a more specific match — it is the "if all else fails, send it this way" entry, typically pointing toward the broader Internet. Home routers usually have just one real routing entry: a default route pointing to the ISP's gateway.

Practice Questions 5 questions

Prerequisite Chain

Counting to 10Counting to 20Understanding ZeroThe Number ZeroCounting to FiveOne-to-One CorrespondenceCombining Small Groups Within 5Addition Within 10Addition Within 20Two-Digit Addition Without RegroupingTwo-Digit Addition with RegroupingAddition Within 100Repeated Addition as MultiplicationMultiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Two-Digit by One-Digit DivisionDivision with RemaindersRemainders and Quotients in DivisionDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueReading and Writing DecimalsComparing and Ordering DecimalsAdding and Subtracting DecimalsMultiplying DecimalsDividing DecimalsDividing FractionsMixed Number ArithmeticOrder of OperationsOperators and ExpressionsArithmetic Operators and Operator PrecedenceComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticSubnetting and CIDR NotationIP Routing and Forwarding

Longest path: 51 steps · 214 total prerequisite topics

Prerequisites (2)

Leads To (7)