Routing Tables

Comprehensive guide to routing tables, longest prefix matching, and how routers determine packet paths through networks

Routing Tables

  • The routing table is a data structure stored in router memory that contains information about network destinations and how to reach them
  • Functions as the router’s “roadmap” - determines the best path for forwarding packets based on destination IP addresses
  • Built and maintained through static routes (manually configured) and dynamic routing protocols (automatically learned)
  • Each entry contains destination network, next-hop IP, outgoing interface, and routing metrics

How Routing Tables Work

  • Router examines destination IP in packet header and performs longest prefix match against routing table entries
  • Longest prefix match wins - most specific route (highest subnet mask) takes precedence over less specific routes
  • If no match found, packet is dropped (unless default route exists)
  • Default route (0.0.0.0/0) acts as “gateway of last resort” when no specific match exists

Routing Table Components

Component Description Example
Destination Network Target network/subnet 192.168.1.0/24
Next Hop IP address of next router 10.0.0.1
Outgoing Interface Local interface to use FastEthernet0/1
Administrative Distance Route source trustworthiness OSPF = 110
Metric Path cost within protocol Hop count, bandwidth
Route Source How route was learned Static, OSPF, EIGRP

Administrative Distance vs Metric

  • Administrative Distance (AD) = “Which routing source should I trust?” (lower is better)
  • Metric = “Which path is best within this routing protocol?” (varies by protocol)
  • AD determines route selection between different protocols (OSPF vs EIGRP)
  • Metric determines route selection within same protocol (multiple OSPF paths)
Route Source Default AD Use Case
Connected 0 Directly attached networks
Static 1 Manually configured routes
EIGRP 90 Cisco proprietary, fast convergence
OSPF 110 Industry standard link-state
RIP 120 Legacy distance-vector

Route Types and Codes

  • Connected (C) - Directly attached networks (interfaces with IP addresses)
  • Static (S) - Manually configured routes using ip route command
  • Dynamic - Learned through routing protocols (OSPF, EIGRP, RIP)
  • Default - Gateway of last resort, shown as S* 0.0.0.0/0

For example: C 192.168.1.0/24 is directly connected, FastEthernet0/0 indicates a connected network

Longest Prefix Match Example

Given destination 192.168.1.50 and these routes:

  • 192.168.0.0/16 (/16 = less specific)
  • 192.168.1.0/24 (/24 = more specific)
  • 0.0.0.0/0 (/0 = least specific, default route)

Router selects 192.168.1.0/24 because /24 provides longest match (most specific)


Vocabulary

Administrative Distance (AD) - Numerical value (0-255) indicating trustworthiness of routing information source; lower values preferred

Metric - Protocol-specific value used to determine best path; hop count for RIP, bandwidth for OSPF

Longest Prefix Match - Algorithm selecting most specific route (highest subnet mask bits) matching destination

Next Hop - IP address of next router in path toward destination network

Convergence - Process of all routers learning about network topology changes and updating routing tables

Gateway of Last Resort - Default route used when no specific route matches destination


Notes

  • Use show ip route to display routing table contents on Cisco devices
  • Routing table size impacts router performance - summarization reduces entries
  • Static routes remain until manually removed or interface goes down (unless tracking configured)
  • Floating static routes use higher AD than dynamic protocols for backup purposes
  • Connected routes automatically appear when interface configured with IP address and comes up
  • Router must know route to destination and source networks for bidirectional communication
  • Load balancing occurs automatically when multiple equal-cost paths exist (up to 4 by default in OSPF/EIGRP)
  • Routing loops prevented through split horizon, poison reverse, and hold-down timers in distance-vector protocols