Skip to content
ENExplore Calculators

Route Lookup Calculator

Run longest prefix match over four candidate routes and see exactly which one forwards a given destination.

About Route Lookup Calculator

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

Worked example

With the default values below, Route Lookup Calculator returns Route Selected of 10.20.30.0/24. Change any input above and every figure here is recalculated in your browser.

Inputs 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

Results

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

Step by step

  1. 1Values used
  2. 2Route Lookup
  3. 3Route Selected= 10.20.30.0/24
  4. 4Winning Prefix Length= 24 bits
  5. 5Candidates That Match= 4
  6. 6Falls Back to the Default Route= No
  7. 7Decision= Of 4 matching route(s), the /24 is the most specific and wins longest prefix match

Assumptions and limits

  • The result is derived only from the 5 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

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.

Route Lookup Calculator – Calculate Route Selected