Comparing Longest Prefix Match and Administrative Distance
This post compares longest prefix match and administrative distance, explaining the distinct roles each plays in router decision-making. Longest prefix match determines which installed route forwards a packet, while administrative distance decides which routing source gets installed into the table.
When a router receives a packet, it has to make a decision: where does this packet go next? That decision process involves two very different concepts, longest prefix match and administrative distance. New students often confuse these two, and honestly, it's an easy mistake to make. They both influence how a router handles routing, but they answer completely different questions. Let's break them down clearly.
Two Different Questions, Two Different Answers
Think of it this way. A router maintains a routing table full of destinations. When a packet arrives, the router asks two questions in sequence:
- Which entry in the routing table best matches this destination? This is where longest prefix match comes in.
- If multiple routing sources learned the same destination, which source should I trust? This is where administrative distance comes in.
These two questions are not interchangeable. One happens at packet-forwarding time, the other happens when populating the routing table in the first place.
Longest Prefix Match: Finding the Best Destination
Longest prefix match is the rule a router uses to select which routing table entry to forward a packet to. The router looks at the destination IP address in the packet and compares it against every entry in its routing table. The entry with the most specific match, meaning the longest subnet mask in CIDR notation, wins.
Here is a simple example. Suppose a router has these entries in its routing table:
10.0.0.0/8 via 192.168.1.1
10.10.0.0/16 via 192.168.1.2
10.10.10.0/24 via 192.168.1.3
0.0.0.0/0 via 192.168.1.254A packet arrives destined for 10.10.10.55. All four entries technically match that address. The 0.0.0.0/0 default route matches everything. The 10.0.0.0/8 also matches. So does 10.10.0.0/16. But 10.10.10.0/24 is the most specific match because it has the longest prefix. The router forwards the packet via 192.168.1.3. Longest prefix match always wins, regardless of any other factors.
Administrative Distance: Choosing the Most Trustworthy Source
Administrative distance (AD) is a value that represents how trustworthy a routing source is. It only matters when two or more routing protocols have learned a route to the exact same destination network. The router uses AD to decide which route gets installed into the routing table. Lower AD wins.
Here are the default AD values you need to know for the CCNA:
- Connected: 0
- Static: 1
- EIGRP (internal): 90
- OSPF: 110
- RIP: 120
- EIGRP (external): 170
- Unknown / unreachable: 255
For example, if both OSPF and RIP learn a route to 192.168.50.0/24, only the OSPF route gets installed into the routing table because its AD of 110 is lower than RIP's 120. The RIP route stays in the background as a candidate but is not used unless the OSPF route disappears.
You can verify routes and their AD values on a Cisco router using:
Router# show ip route
Router# show ip route 192.168.50.0The output will show the AD and metric in brackets, like [110/2], where 110 is the AD and 2 is the metric.
The Key Difference in Route Selection
Here is the critical distinction to lock in before exam day:
- Administrative distance: Determines which route gets installed into the routing table when multiple sources advertise the same prefix.
- Longest prefix match: Determines which installed route gets used to forward a packet.
AD operates before the packet arrives, shaping what the routing table looks like. Longest prefix match operates in real time, deciding the forwarding path for every individual packet. In network decisions and route selection, both mechanisms are essential, they just operate at different stages of the process.
What's Next
Now that you understand how routers select and use routes, the next logical step is diving deeper into one of the most common dynamic routing protocols you will encounter: OSPF. Understanding how OSPF builds its link-state database and calculates paths will solidify everything you have learned here about administrative distance and routing comparisons. Stay tuned for an OSPF fundamentals walkthrough coming up next in the series.
If you want to study these concepts alongside a structured guide, the Cisco Press CCNA 200-301 Official Cert Guide by Wendell Odom covers longest prefix match and administrative distance in excellent detail with additional practice scenarios.
Tools and resources for this topic
- Wendell Odom CCNA Vol 1 — Covers networking fundamentals, switching, and routing basics.
- Wendell Odom CCNA Vol 2 — Covers advanced routing, WAN, infrastructure services, and security.