Switching & routing

Route table lookup and next hop

A router compares a packet destination against its route table, picks the longest matching prefix and forwards to that route next hop.

IngressIngressGi0/1Gi0/1Gi0/2Gi0/2PacketSource host192.0.2.10Source host — 192.0.2.10Router R1192.0.2.1Router R1 — 192.0.2.1Next hop A198.51.100.1Next hop A — 198.51.100.1Next hop B198.51.100.2Next hop B — 198.51.100.2
Legend

Current step

Packet arrives at R1

The router reads the destination address and looks it up in the route table.

Source address
192.0.2.10
Destination address
203.0.113.130
Longest-prefix match always wins: a /25 beats a /24 for the same destination regardless of metric. The default route 0.0.0.0/0 is used only when nothing more specific matches.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Tags

  • routing
  • route-table
  • longest-prefix
  • next-hop
  • layer-3

Lessons using this diagram