Definition

A routing table associates destination prefixes with forwarding information, including an outgoing interface and, where needed, a next-hop router. Among matching prefixes, select the longest.

Worked example

For destination 200.23.19.7:

RouteRangeMatches?
200.23.16.0/20200.23.16.0-200.23.31.255Yes
200.23.18.0/23200.23.18.0-200.23.19.255Yes: selected
0.0.0.0/0All IPv4 addressesYes

The /23 wins and forwards to the remote next hop 200.24.7.2. Removing it makes /20 win; the default does not override the /20.

Direct versus remote delivery

For a connected destination network, send on the attached link. For a remote destination, send to an adjacent router’s address on the outgoing link. The packet’s final IP destination remains the remote destination during ordinary forwarding.

Page 18 labels routes S (static) and C (connected). Its Next-hop column contains remote neighbor addresses for S entries, but local interface addresses for C entries. For example, 130.192.3.2 is R2; 130.192.3.1 is R1’s local interface on the same /30 link.

Route cost

The example’s R1-R2-R3 path costs 1+1=2, versus 5 on R1-R3. Thus R1 uses R2 for R3’s LAN. Cost helps choose routes to a prefix; it does not let a shorter matching prefix beat a longer one.

Common mistakes

  • Picking the lowest cost across all matching prefixes before checking specificity.
  • Treating the next hop as the final destination.
  • Reading a connected route’s local address as a remote next hop.

Source

Lecture 01 - IPv4 Addressing and Routing, PDF pages 13-15 and 17-18. Range calculations and cautions are added study explanation.

For how routes are learned, selected and used during failures, continue to Routing Forwarding and Convergence and Lecture 04 - Forwarding and Routing Algorithms.