The Forwarding Decision
A routing table full of overlapping routes looks chaotic until you know the algorithm. Every router resolves it the same way, in the same order: longest prefix match first, then administrative distance, then metric. Master that sequence and most route-selection questions answer themselves.
- Explain how a router chooses among multiple routes to the same or overlapping destinations.
- Apply the order: longest prefix match → administrative distance → metric.
- Name the route sources (connected, static, dynamic) and their show ip route codes.
- Identify the gateway of last resort and explain when it is used.
- Walk a packet through a router's decision using a concrete routing table.
The three questions a router asks
A router receives a packet and must answer one question: out which interface, and to which next hop, do I send this? It does not consider the whole table at once like a human scanning a list. It applies a strict, ordered procedure. The order matters because a careless student often compares the wrong things — for example, preferring a low administrative distance over a route that is simply more specific.
172.16.0.0/16 does not beat an OSPF route (AD 110) to
172.16.1.0/24 for a packet sent to 172.16.1.5, because the /24 is more specific.
Step 1 — longest prefix match
The router compares the destination address against every route and keeps only those whose prefix contains the address. Among the matches, the one with the longest prefix length (the most specific) wins. Prefix length beats every other consideration, including how the route was learned. This is intuitive: a /32 is literally one host, so it is the most precise statement the router can make.
Consider this table:
O 10.1.0.0/16 [110/2] via 192.168.1.2
O 10.1.1.0/24 [110/3] via 192.168.1.2
S 10.1.1.128/25 [1/0] via 192.168.1.6
A packet to 10.1.1.200 matches all three prefixes, but the /25 contains it and is longest,
so it is forwarded to 192.168.1.6. A packet to 10.1.2.5 matches only the /16 and goes to
192.168.1.2. Longest prefix match is why summarisation works: the router sends most traffic to the
summary and only the specific exceptions elsewhere.
Step 2 — administrative distance
If two or more routes have the same prefix length and both match, the router prefers the one from the more trusted source, measured by administrative distance (AD). Lower is better. This is the tie-breaker between routing protocols and static routes, and it is a fixed, vendor-defined number (connected 0, static 1, EIGRP 90, OSPF 110, RIP 120).
Example: the table holds an OSPF route and a static route to the very same
192.168.20.0/24. Both have the same prefix length, so AD decides — static (1) beats
OSPF (110), and only the static route is installed in the forwarding table (the OSPF one is kept aside
as a candidate). Floating static routes exploit this deliberately by assigning a high AD so the route
waits until the primary disappears.
Step 3 — metric
If the prefix length and the administrative distance are both equal — that is, two routes to the same prefix came from the same protocol — the router compares the protocol’s metric. Lower is better. The metric is what each protocol uses to rank paths it learned:
| Protocol | Metric |
|---|---|
| RIP | Hop count (maximum 15) |
| OSPF | Cost = reference bandwidth / bandwidth (default reference 100 Mbps → 108/BW) |
| EIGRP | Composite: bandwidth and delay (with load and reliability as optional weights) |
If the metrics are also equal, the router installs both routes and performs equal-cost load balancing across them. That is the end of the cascade: longest prefix, then AD, then metric, then share the load.
Gateway of last resort
Suppose no route matches the destination at all. The router then checks for a default route, shown in the table as the gateway of last resort. A default route is the prefix 0.0.0.0/0 (IPv4) or ::/0 (IPv6): a zero-length prefix that matches everything. Because it is the least specific possible prefix, longest-prefix match guarantees it is used only when nothing else fits.
Router# show ip route
Gateway of last resort is 203.0.113.1 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 203.0.113.1
If there is no default route and nothing matches, the router drops the packet and typically returns an ICMP “destination unreachable” to the sender. Routers never invent a path; a packet to an unknown network is simply discarded.
Walking a packet through the decision
Take a router with the following IPv4 table and trace three packets:
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
S 172.16.0.0/16 [1/0] via 192.168.1.2
O 172.16.1.0/24 [110/2] via 192.168.1.3
O 172.16.1.128/25 [110/3] via 192.168.1.4
S* 0.0.0.0/0 [1/0] via 192.168.1.1
- Packet to 172.16.1.200. Matches /16, /24, /25, and the default. Longest is the /25, so it goes to 192.168.1.4. Note that the more trusted static /16 loses to the more specific OSPF /25 — specificity beats distance.
- Packet to 172.16.2.10. Matches /16 and the default. Longest is the /16 (static), so it goes to 192.168.1.2.
- Packet to 8.8.8.8. Matches only the default, so it goes to 192.168.1.1, the gateway of last resort.
Now add a same-prefix conflict: an EIGRP route to 172.16.0.0/16 (AD 90) appears beside
the static route (AD 1). The prefix lengths are equal, so AD decides — the static route stays
installed and the EIGRP route waits. Finally, if a second OSPF route to
172.16.1.0/24 with a lower metric than [110/2] appears, metric decides and the cheaper one
is installed.
show ip route displays the selected route for each prefix. Alternate routes
(such as the OSPF version of a prefix a static route won) exist as candidates but are not shown unless
you look with protocol-specific commands such as show ip ospf route.
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.