How Routing Tables Work

Ch. 1 of 515 mins3 Tasks

Demystify the router forwarding engine. Learn how routers populate connected routes, evaluate candidate paths, and execute longest prefix matching.

Track Series

Chapters in this Track (Ch. 1 of 5)

1How Routing Tables Work
15m

A router is fundamentally an internetwork post office. While a Layer 2 switch forwards frames based on physical MAC addresses within a single room, a router inspects Layer 3 IP headers to steer packets across buildings, cities, and oceans. At the center of every routing decision sits a critical internal database: the Routing Table (Forwarding Information Base).

If a destination IP address does not match any entry in the routing table, the router does not guess or broadcast inquiries across the network. It immediately drops the packet and discards it into the digital void. In this chapter, you will learn how routers build their internal tables, how they choose between competing routes, and how the principle of Longest Prefix Match governs every forwarding decision.

The Life Cycle of Connected and Local Routes

When you power on a brand-new router, its routing table is completely empty. The very first entries appear automatically through Directly Connected Networks. As soon as you assign an IP address and subnet mask to a physical interface and issue the no shutdown command, the router kernel performs a carrier check.

If the physical network port detects electrical current and line framing (Status UP and Protocol UP), the router automatically installs two distinct routes for that single interface into its table:

  • C (Connected): Represents the entire subnet attached to that wire (for example, 192.168.1.0/24). Any packet addressed to an IP in that range can be delivered directly via local ARP resolution.
  • L (Local): Represents the router own specific interface IP (for example, 192.168.1.1/32). This host route allows the router internal CPU to intercept packets destined for itself, such as SSH management sessions or ping diagnostics.
Route Type Origin Source Administrative Distance Hardware Overhead Typical Use Case
Connected (C) Active physical port 0 Zero Local switch LANs
Local (L) Router interface /32 0 Zero Router management IP
Static (S) Manual administrator config 1 Very Low Branch office links
Dynamic (O/B/R) OSPF, BGP, or RIP protocols 110 / 20 / 120 Medium to High Complex enterprise mesh

The Longest Prefix Match Rule

What happens when a router table contains multiple valid routes that could match a destination packet? For example, suppose a packet is destined for 10.1.2.50, and the router table contains entries for 10.0.0.0/8, 10.1.0.0/16, and 10.1.2.0/24. Which path does the router choose?

In computer networking, the router always selects the route with the Longest Prefix Match (the highest number of matching mask bits). In this scenario, the router chooses 10.1.2.0/24 because twenty-four matching bits is more specific than sixteen or eight bits. The most specific route always wins, regardless of administrative distance or protocol origin.

This principle gives network designers extraordinary precision. You can configure a broad default route for general internet traffic, while injecting specific /24 or /28 routes to steer sensitive internal traffic across dedicated high-speed links.

Next-Hop vs Exit-Interface Forwarding

When defining a route, an administrator can specify either an Exit Interface (such as GigabitEthernet0/1) or a Next-Hop IP Address (such as 10.0.0.2). Understanding the difference is vital for link stability.

On point-to-point links (like serial lines or dedicated fiber cables), specifying the exit interface is efficient because only one possible receiver exists on that wire. However, on multi-access Ethernet networks with switches, specifying only an exit interface forces the router to perform an ARP broadcast for every foreign IP, quickly exhausting switch memory. Always specify the next-hop IP address on Ethernet networks.

Hands-On Lab Practice

In this lab exercise, you will log into an enterprise router, inspect its automatically generated Connected (C) and Local (L) routing table entries, trace route lookup decisions, and verify direct packet forwarding across local interfaces.

Take note of how the router displays network masks in slash notation alongside the traditional dotted decimal representation. Familiarity with both formats ensures clear communication across technical teams.

Hands-On Practice Checklist

Progress:0 / 3

Perform actions on the practice lab canvas on the right. Tasks automatically check off as you connect cables and run commands.

Task 1: Inspect Routing Table on Core Router

Click Core Router, open CLI, and run "show ip route" to view automatically populated Connected (C) and Local (L) routes.

Task 2: Ping Router Gi0/0 from LAN Workstation

From LAN PC Terminal, ping the router local interface at 192.168.1.1. Confirm 0% packet loss.

Task 3: Verify Direct Route Forwarding to Server

From LAN PC Terminal, ping Local Server at 192.168.2.50 across the router. Confirm packet delivery.