Router Forwarding: Longest Prefix Match Logic

200-301 By islever Editorial Last updated

Determine how a router makes a forwarding decision by default

Short answer

C The router forwards the packet via prefix 172.31.0.0/25 because it is the longest matching prefix.

Question

A packet from a company's branch office is destined to host 172.31.0.1 at headquarters. The sending router has three possible matches in its routing table for the
packet: prefixes 172.31.0.0/16, 172.31.0.0/24, and 172.31.0.0/25. How does the router handle the packet?
  1. It sends the traffic via prefix 172.31.0.0/24.
  2. It sends the traffic via prefix 172.31.0.0/16.
  3. It sends the traffic via prefix 172.31.0.0/25. Correct Answer
  4. It sends the traffic via the default gateway 0.0.0.0/0.

Key Takeaways

Tests the Longest Prefix Match rule where the router prioritizes the most specific route (longest subnet mask) over less specific ones.

A router forwarding a packet to 172.31.0.1 with multiple matching routes (/16, /24, /25) selects the longest prefix match, which is /25.

Common mistake: Choosing A (/24) or B (/16) because they are 'larger' networks or appear first; however, specificity dictates the choice, not size or order.

Expert Analysis

Longest Prefix Match Rule

The router selects the route with the longest subnet mask that matches the destination IP address. This is known as the Longest Prefix Match rule.

Analysis of Options

  • 172.31.0.0/25: Mask /25 (longest) covers 172.31.0.0 to 172.31.0.127. Host.1 is in this range.
  • 172.31.0.0/24: Mask /24 covers 172.31.0.0 to 172.31.0.255. Host.1 is in this range.
  • 172.31.0.0/16: Mask /16 covers 172.31.0.0 to 172.31.255.255. Host.1 is in this range.
  • 0.0.0.0/0: Default route, but specific routes are preferred.

Since all three specific routes match, the router chooses the one with the most bits: /25.

Operational Consequence

If you choose a shorter prefix (like /24 or /16), traffic will be misrouted to a less specific network, potentially causing connectivity issues or security breaches if the /25 network was intended for isolation.

Decision Context

This tests knowledge of routing table lookup mechanics (Objective 3.2). Changing the destination to 172.31.0.200 would still match /24 and /16, but not /25, flipping the answer to B.

Exam Strategy

When facing routing questions with multiple valid routes, always compare the subnet masks. The correct answer is invariably the one with the highest number of bits (longest mask). Do not consider administrative distance unless the prefixes are identical.

Frequently Asked Questions

Why doesn't the router use the default gateway?

The default gateway (0.0.0.0/0) is only used if no other more specific routes match the destination IP.

What if two routes have the same prefix length?

Then the router uses Administrative Distance to break the tie, choosing the lower value.

More 200-301 FAQ →

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 3 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 3

  1. Goh0503 👍 14
    Answer: C how a router makes a forwarding decision by a Longest match >>b Administrative distance >>c Routing protocol metric, in this order
  2. maximus_007 👍 1 Answered C
    Probably one of the easiest questions related to longest prefix. Sheeeesh!
  3. 2b081f1 👍 1 Answered C
    c is correct

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All 200-301 Questions

Access 220 questions with complete answers and detailed explanations.

View Full 200-301 Practice Test →

← Back to 200-301 Study Guide