The first rule of the lookup
RFC 1812, the requirements document for IPv4 routers, makes longest-match the basic forwarding rule. Every other tie-breaker you learn for the CCNA happens earlier, while the routing table is being built: administrative distance and metric decide which single route survives for each prefix, and the lookup then chooses among prefixes.
This is v1.1 topic 3.2, the default forwarding decision, and part of v2.0 topic 3.1. The surrounding material, from route codes to floating statics, is in the routing table and static routes study area.
Reading prefix lengths off show ip route
Routing-table output hides the prefix length in one place. When every subnet of a classful network shares one mask, IOS prints a heading such as 172.16.0.0/24 is subnetted, 2 subnets and drops the mask from the entries beneath it. When the masks differ, the heading says variably subnetted and each entry carries its own /length. Read the heading before you compare entries.
One destination, four candidates
| Entry | Source [AD/metric] | Address range | Contains it? |
|---|---|---|---|
| 172.20.0.0/16 | Static [1/0] | 172.20.0.0 to 172.20.255.255 | Yes, on 16 bits |
| 172.20.96.0/20 | Static [1/0] | 172.20.96.0 to 172.20.111.255 | Yes, on 20 bits |
| 172.20.100.0/22 | OSPF [110/40] | 172.20.100.0 to 172.20.103.255 | Yes, on 22 bits: used |
| 172.20.104.0/22 | OSPF [110/20] | 172.20.104.0 to 172.20.107.255 | No |
The third octet does the work. 101 is 01100101. The /20 fixes its first four bits (0110, matching 96); the /22 fixes six (011001, matching 100). 104 is 01101000, which breaks at the fifth bit, so that /22 never enters the contest.
Two jobs, done at different times
Building the table
For each prefix, competing sources are ranked by AD, and paths within the winning source by metric. One best entry per prefix is installed.
Finding candidates
When a packet arrives, every installed entry whose range contains the destination is a candidate, whatever its source.
Choosing
The candidate with the longest prefix forwards the packet. If nothing matches and there is no default route, the router drops it.
The lookup as a pipeline
- 0000 Packet to 172.20.101.77
- 0010 Three of the four entries contain the address
- 0020 /22 beats /20 and /16
- 0030 The OSPF next hop, despite AD 110
Frames on Longest prefix match
For every frame, write the destination’s octet in binary where the candidate prefixes diverge, then cross out what does not contain it.
Practice frames written by our editors for study, not Cisco items. The 200-301 exam itself mixes multiple choice, drag-and-drop and lab-style items.
Frame 001 of 006 · 0 answered · 0 ok
Keys
1–5 or A–E pick an option (on choose-N frames they toggle; then Check answer) · ← → previous / next frame · ↑ ↓ move in the frame list
- Frame 001 of 006
Refer to the exhibit. A packet destined for 10.10.10.5 arrives at the router. Which route does the router use to forward it?
S 10.10.0.0/16 [1/0] via 192.168.1.4O 10.10.10.0/24 [110/3] via 192.168.1.3O 10.10.10.0/26 [110/2] via 192.168.1.2S 10.10.10.0/28 [1/0] via 192.168.1.1Pick an option. The verdict shows here; open the note under any option to see why.
Note on A
The /24 covers 10.10.10.5, but a /26 and a /28 in the table cover it more specifically.
Note on B
This /26 matches too, yet the /28 is longer, and prefix length is compared before AD or metric.
Note on C
The /16 static route has the best AD, but it is the least specific match, so it serves only addresses no longer prefix covers.
Note on D
Correct: 10.10.10.5 falls inside 10.10.10.0/28, the longest matching prefix, so this route forwards the packet.
Best answer: D · why
The router compares prefix length first. All four routes contain 10.10.10.5, and the /28 (10.10.10.0 to 10.10.10.15) is the most specific, so it wins. Administrative distance and metric only matter between routes to the same prefix, so the OSPF costs and the AD of 1 on the /16 never come into play here.
- Frame 002 of 006
What routing principle states that when a router has multiple routes to the same destination network with different prefix lengths, it will select the route with the most specific prefix?
Pick an option. The verdict shows here; open the note under any option to see why.
Note on A
Correct: longest prefix match means the route whose prefix matches the most bits of the destination is used, whatever its source.
Note on B
Equal-cost load balancing spreads traffic over routes to the same prefix with equal metrics; it does not prefer a more specific prefix.
Note on C
Administrative distance chooses between sources offering the same prefix, not between different prefix lengths.
Note on D
Metrics compare routes from one protocol to the same prefix, and a more specific prefix wins before any metric is compared.
Best answer: A · why
For each packet, the router looks for the route whose prefix matches the most leading bits of the destination address. That is the longest prefix match, and it comes before every other rule: a /28 static route, a /26 OSPF route and a default route can all match one address, and the /28 wins. AD and metric only settle ties between routes to the same prefix.
- Frame 003 of 006
When a router is presented with multiple routes to a destination that differ in both prefix length and administrative distance, how are routing decisions made?
Pick an option. The verdict shows here; open the note under any option to see why.
Note on A
Correct: the most specific prefix wins outright, and AD only matters when two sources offer the same prefix length.
Note on B
AD never overrides a more specific prefix: a /24 OSPF route beats a /16 static route for an address inside the /24.
Note on C
Metrics are never added across routes, and the lower metric, not the higher one, is preferred.
Note on D
Routers are deterministic: among equal routes they use AD, then metric, and may load-balance equal-cost paths instead of picking at random.
Best answer: A · why
Think of it as two separate steps. When building the routing table, the router compares sources only for the same prefix: lowest AD wins, then lowest metric. When forwarding, it uses the longest prefix that matches the destination. So a more specific OSPF route (AD 110) beats a less specific static route (AD 1) for addresses inside it, and AD never overrides prefix length.
- Frame 004 of 006
A router’s routing table contains a specific OSPF-learned route for 192.168.100.0/25 and a static default route 0.0.0.0/0. If a packet is destined for 192.168.100.50, how is it forwarded?
Pick an option. The verdict shows here; open the note under any option to see why.
Note on A
The static default has the lower AD, but 0.0.0.0/0 is the least specific match, so the /25 wins.
Note on B
Correct: 192.168.100.50 falls inside 192.168.100.0/25 (.0 to .127), and that /25 is far more specific than the /0 default.
Note on C
The routes have different prefix lengths, so they are not equal-cost paths and the router does not load-balance.
Note on D
Overlapping routes are normal; the router uses longest prefix match instead of dropping the packet.
Best answer: B · why
The /25 covers 192.168.100.0 to 192.168.100.127, so it matches .50 with 25 bits, while the default route matches with 0 bits. Longest prefix match picks the /25 even though the OSPF AD of 110 is higher than the static route’s 1. The default route is used only for destinations that no more specific route covers.
- Frame 005 of 006
When a router’s routing table contains both a host route (/32) and a broader network route that overlap, how does the router determine which route to use for packet forwarding?
Pick an option. The verdict shows here; open the note under any option to see why.
Note on A
Correct: a /32 matches all 32 bits of one address, so for that host it beats any broader route, whatever the AD.
Note on B
Different prefix lengths are never equal matches, so the router does not load-balance between them.
Note on C
AD is used only between routes with the same prefix length; a more specific route wins even with a higher AD.
Note on D
Covering more addresses makes a route less specific, and the router prefers the most specific match.
Best answer: A · why
A host route (/32) matches one exact address. For packets to that address it is the longest possible match and always wins, regardless of its source or AD. Packets to any other address in the broader network still use the broader route. Host routes are common for loopbacks, and as static routes they can steer one destination differently.
- Frame 006 of 006
The routing table holds 10.10.0.0/16 and 10.10.10.0/24, both with the same administrative distance. Which route does the router use for a packet to 10.10.10.25?
Pick an option. The verdict shows here; open the note under any option to see why.
Note on A
Correct: 10.10.10.25 matches 24 bits of 10.10.10.0/24 but only 16 bits of 10.10.0.0/16, so the longer /24 is used.
Note on B
Routes with different prefix lengths are not candidates for load balancing; only equal routes to the same prefix are.
Note on C
A larger network is a less specific one, and the router prefers the most specific match.
Note on D
Metrics only compare routes to the same prefix; here the prefixes differ, so prefix length settles it first.
Best answer: A · why
Both routes contain 10.10.10.25, but the /24 matches 24 leading bits and the /16 only 16. The router always forwards on the longest matching prefix, so the /24 wins; AD and metric are not compared, because the prefixes differ. A packet to 10.10.20.1 would use the /16, since the /24 does not contain it.
Before you commit to an answer
- Find the octet where the candidate prefixes differ and convert it to binary.
- Cross out every entry whose range does not contain the destination.
- Of the survivors, keep the one with the most prefix bits.
- Compare AD, then metric, only between survivors with the same network and prefix length.
- If no entry survives, look for a gateway of last resort before you conclude the packet is dropped.
Where the OSPF routes came from
The /22 that won here was learned through OSPF. On a shared Ethernet segment, how OSPF routers exchange those routes depends on which router holds the designated role, which is the subject of OSPF DR and BDR election.
References
- [1]RFC 1812: Requirements for IP Version 4 Routers
- [2]RFC 4632: Classless Inter-domain Routing (CIDR)
- [3]Cisco: What Is Administrative Distance?Checked October 29, 2026.
- [4]Cisco Learning Network: CCNA v1.1 exam topicsChecked October 29, 2026.