Skip to content

STAGE 04 / NETWORKING FOUNDATIONS

Routing tables and longest-prefix matching

Read routing table entries and select the forwarding route using longest-prefix matching.

Before you begin

Read subnetting and local delivery.

A route is a forwarding instruction

A routing-table entry has a destination prefix and a way to reach it, often a next-hop address or outgoing interface. Connected routes describe attached networks. Static routes are configured by a person; routing protocols learn routes from other routers. A default route, 0.0.0.0/0 for IPv4, matches destinations without a more specific installed route.

To forward a packet, compare its destination with the installed routes and choose the longest matching prefix. A /24 match is more specific than a /16 match. Administrative distance helps select between sources offering the same prefix; metrics compare paths according to the routing protocol. Do not compare every route’s distance before checking its prefix.

Route lookup example

Suppose routes exist for 10.0.0.0/8 via A, 10.1.0.0/16 via B and 10.1.2.0/24 via C. A packet for 10.1.2.50 uses C. A packet for 10.1.9.50 uses B. A return route is also necessary for a successful conversation.

A floating static route has a higher administrative distance than the route it backs up. IPv6 uses the same longest-prefix idea, with ::/0 as the default. Interface-only static routes on multiaccess networks have different implications from next-hop routes; use the exercise’s specified design.

Verification commands

Use these viewing commands to inspect the idea in this lesson. Start in the environment shown above each example.

Cisco IOS · privileged EXEC
show ip route

Command reference · enter in the stated environment; output varies by device.

Practical exercise

With routes 0.0.0.0/0, 192.168.0.0/16 and 192.168.10.0/24, choose the matching prefix for 192.168.10.75.

Show the answer and explanation

All three match, but /24 is the longest match. Its installed next hop is used. The /16 and default are less specific.

QUICK KNOWLEDGE CHECK

Check your understanding

Which installed route wins for 10.1.2.3?

Related labs and exercises

Sources & content checks

Technical references checked on 25 October 2026. These are original teaching explanations, not official Cisco course material. See how content and lab validation are described.

Your progress

Mark this complete when you can explain the example and do the exercise.