Week 6 · Lesson 18

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.

CCNA 200-301 Domain 3.0 IP Connectivity Verified 2026-10-11
Learning objectives
Part 1

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.

The forwarding algorithm, in order 1. Longest prefix match 2. Lowest AD 3. Lowest metric Equal? load balance No route matches at all → use the default route (gateway of last resort). No default either → drop the packet and send ICMP unreachable. The first test is always specificity, never AD. A /24 beats a /16 even if the /16 came from a “more trusted” source.
Route selection is a cascade. Only routes that match the destination are considered; the most specific wins immediately. AD and metric are tie-breakers among routes to the same prefix length.
Exam tip — the order is not negotiable Longest prefix match first, then administrative distance, then metric. A static route (AD 1) to 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.
In this lesson · select a part to jump

Reference table · select a row

Key ideas & exam traps · select one

Part 2

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.

Part 3

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.

Definition — administrative distance Administrative distance is a 0–255 trust rating used to choose between routes to the same prefix learned from different sources. Lower wins.
Part 4

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:

ProtocolMetric
RIPHop count (maximum 15)
OSPFCost = reference bandwidth / bandwidth (default reference 100 Mbps → 108/BW)
EIGRPComposite: 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.

Part 5

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.

Part 6

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

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.

Note — the table shows the winner only Ordinary 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.
Key terms

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.

Key terms · select a term

Part 7 · Your turn

Review

Check what you have learned with these review questions.

Review · 5 questions

Sources

Sources & references

  1. Cisco. CCNA (200-301) Exam Topics. cisco.com.
  2. IETF. Request for Comments (RFCs). rfc-editor.org.
  3. 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.