A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Routing Table Concepts

Graduate Depth 82 in the knowledge graph ☐ I know this ☆ Set as goal
11topics build on this
338prerequisites beneath it
See this on the map →
IP Routing and Forwarding→→Distance-Vector Routing ProtocolsLink-State Routing Protocols+1 more
routing-table route-lookup next-hop longest-prefix-match

Core Idea

A routing table maps destination addresses to outgoing interfaces and next-hop addresses. Routers use longest-prefix matching to find the most specific route for each packet destination. Efficient routing table lookup requires data structures like tries or hash tables to handle millions of routes at line-rate speeds.

Explainer

From IP routing basics, you know that routers forward packets hop by hop toward their destinations. The routing table is the data structure that makes each forwarding decision possible — it is essentially the router's map of the network. Each entry in the table says: "To reach this destination network, send the packet out this interface to this next-hop address." When a packet arrives, the router extracts the destination IP address from the header and consults the table to decide where to send it next.

A routing table entry typically contains several fields: the destination network (expressed as a prefix like 192.168.1.0/24), the next-hop address (the IP of the neighboring router that gets the packet closer to its destination), the outgoing interface (which physical or logical port to use), a metric (a cost value used to compare routes), and the route source (how the router learned this route — directly connected, statically configured, or via a routing protocol). Routes learned from different sources carry different levels of trust, expressed as administrative distance — a directly connected network is more trustworthy than a route learned from an external routing protocol, so it takes priority if both claim to reach the same destination.

The key algorithm that makes routing tables work is longest-prefix match. When a router looks up destination 192.168.1.50, it might find two matching entries: 192.168.0.0/16 (a broad route covering the entire 192.168.x.x range) and 192.168.1.0/24 (a more specific route covering just the 192.168.1.x subnet). The router always chooses the longest prefix — the /24 in this case — because a more specific route represents more precise knowledge about where that traffic should go. This is analogous to mailing a letter: if you know both "somewhere in New York State" and "123 Main Street, Buffalo, NY," you use the more specific address. The default route (0.0.0.0/0) is the shortest possible prefix and matches everything — it is the route of last resort when no more specific entry exists.

Routing tables are populated through three mechanisms. Directly connected routes are added automatically when an interface is configured with an IP address. Static routes are manually configured by an administrator — useful for simple networks or specific policy overrides. Dynamic routes are learned from routing protocols like OSPF or BGP, which exchange reachability information with neighboring routers and automatically update the table as network topology changes. In a large network, the routing table may contain hundreds of thousands of entries, and the router must perform a lookup for every single packet at line rate — potentially millions of lookups per second. This is why efficient data structures like tries (prefix trees) are used in hardware, allowing the longest-prefix match to complete in a fixed number of memory accesses regardless of table size.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Subnetting and CIDR Notation → IP Routing and Forwarding → Routing Table Concepts

Longest path: 83 steps · 338 total prerequisite topics

Prerequisites (1)

Leads To (3)