Route Lookup Calculator
Run longest prefix match over four candidate routes and see exactly which one forwards a given destination.
Inputs
Route Selected
10.20.30.0/24
Winning Prefix Length
24bits
Candidates That Match
4
Falls Back to the Default Route
No
Decision
Of 4 matching route(s), the /24 is the most specific and wins longest prefix match
Step by step
Values used
Destination IP = 10.20.30.77; Candidate route 1 = 10.0.0.0/8; Candidate route 2 = 10.20.0.0/16; Candidate route 3 = 10.20.30.0/24; Candidate route 4 = 0.0.0.0/0
Route Lookup
A route matches when (destination AND mask) equals (network AND mask); of all matches, the one with the longest prefix is installed as the forwarding decision.
Route Selected
= 10.20.30.0/24
Winning Prefix Length
= 24 bits
Candidates That Match
= 4
Falls Back to the Default Route
= No
Decision
= Of 4 matching route(s), the /24 is the most specific and wins longest prefix match
How it works
Forwarding is not a search for the first match but for the most specific one, which is why a router with both a /8 and a /24 covering an address always uses the /24. Administrative distance and metrics never override this — they only choose between routes of identical prefix length. Most "the traffic is taking the wrong path" tickets are longest prefix match doing exactly what it should, and stepping through the candidates is the fastest way to prove whether the problem is the route table or the policy above it.
Formula
Route Lookup
A route matches when (destination AND mask) equals (network AND mask); of all matches, the one with the longest prefix is installed as the forwarding decision.
- longest prefix match
- Most specific matching route wins, regardless of protocol or metric
- /0
- The default route — matches everything and always loses to anything more specific
- mask
- 32-bit mask derived from the prefix length
Frequently Asked Questions
How is Route Lookup calculated?
A route matches when (destination AND mask) equals (network AND mask); of all matches, the one with the longest prefix is installed as the forwarding decision. Forwarding is not a search for the first match but for the most specific one, which is why a router with both a /8 and a /24 covering an address always uses the /24. Administrative distance and metrics never override this — they only choose between routes of identical prefix length.
Why does Route Lookup matter?
Most "the traffic is taking the wrong path" tickets are longest prefix match doing exactly what it should, and stepping through the candidates is the fastest way to prove whether the problem is the route table or the policy above it.
What values do I need to enter?
This calculator takes 5 inputs: Destination IP, Candidate route 1, Candidate route 2, Candidate route 3, Candidate route 4. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.
Does the routing protocol matter here?
Not for this step. Prefix length is compared first, so an OSPF /24 beats a static /16 even though static has a far better administrative distance. Distance is only used when two protocols offer the same prefix.