Route tables and longest prefix match
A router makes a local decision
A router forwards a packet toward its destination by consulting routing information. It does not need to know every hop in advance. A route usually describes a destination prefix, a next hop or outgoing interface, and attributes such as its origin. A connected route describes a directly attached network; a local route represents an address belonging to the router itself. A static route is configured manually. Dynamic routes are learned through routing protocols.
RIB versus FIB
The routing information base (RIB) stores routing information used by the control plane to select routes. The forwarding information base (FIB) holds information used to forward packets, often in an optimized representation. Implementations differ: not every candidate appears in the FIB, and an installed route may still need neighbor resolution. In this lesson use a single forwarding table with no policy routing or equal-cost alternatives.
Longest prefix match: worked example
First find all installed prefixes containing the destination address. Then choose the most specific prefix (largest prefix length). In the fictional table below, 10.20.4.9 matches four rows and uses N4; 10.20.4.10 uses N3; 10.20.8.1 uses N2; 192.0.2.7 uses N1. A default /0 matches any address of its address family. IPv6 uses the same prefix idea, with ::/0 as default and /128 as an exact host route.
0.0.0.0/0 N110.20.0.0/16 N210.20.4.0/24 N310.20.4.9/32 N4From route to next hop
If a route specifies a gateway, the device must know how to reach that gateway. Recursive resolution means consulting routing information until an appropriate outgoing interface and next hop are established. On Ethernet, ARP or IPv6 Neighbor Discovery may then provide the link-layer destination. An unresolved gateway, recursive dependency or unusable interface can prevent forwarding. On a directly attached network the next hop is normally the destination itself. The IP destination stays the same during ordinary routing; link headers are rebuilt as needed and TTL or Hop Limit decreases.
Practice and common mistakes
Do not choose the first displayed row or the route with the smallest numeric metric across different prefixes. For a lookup of 10.20.4.10, remove N3 from the paper table: N2 now wins. Remove N2 as well: N1 wins. Remove the default and look up 192.0.2.7: no matching route exists. A route match is not proof of delivery. Use the staged worksheet and then learn to build routes in both directions.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Route tables and longest prefix match — knowledge check
Apply routing and static-route reasoning to fictional networks.
Which row handles 10.20.4.9 in the lesson table?
Which row handles 10.20.8.1?
What does a local route normally represent?
Which structure is used for forwarding decisions?
A matching route has a gateway that cannot be resolved. What follows?