Longest Prefix Match Calculator
Find the most specific matching route.
Longest Prefix Match Calculator: inputs and results
Enter an IP address, CIDR prefix, or range. Then check its first and last address below.
Calculated Boundaries & ParametersReady
Key Capabilities
- •100% Client-Side: Zero telemetry or server latency.
- •RFC Compliant: Exact 32-bit and 128-bit integer precision.
- •Quick Copy: Instant access to CIDR, mask, and range bounds.
- •Cross-Platform: Works on desktop, tablet, and mobile browsers.
Related IPv4 Subnetting & RangeAll Tools
IPv4 Range Calculator
Find address boundaries from a prefix.
IPv4 Subnet Calculator
Calculate subnet details from address and mask.
Network Address Calculator
Find the subnet’s network address.
IPv4 Broadcast Address Calculator
Find broadcast addresses where applicable.
First and Last Address Calculator
Identify a range’s endpoints.
Usable IPv4 Host Range Calculator
Apply the selected subnet-use rules.
How Longest Prefix Match Calculator Works?
This tool works by testing a destination address against every route in a routing table and selecting the matching route with the longest prefix length.
Enter the routing table
Paste routes such as
0.0.0.0/0,10.0.0.0/8, and10.1.2.0/24.Enter the destination
Type a destination address, such as
10.1.2.77.Find every matching route
A route matches when
destination AND maskequals the route network.Pick the longest prefix
Among the matches, the route with the highest prefix length wins. The default route matches everything and wins only when nothing else matches.
Longest Prefix Match Calculator Formula
The formula is Best Route = argmax(p) over routes where (Destination AND Mask(p)) = Route Network.
Match test
(D AND Mask(p)) = NRuns for every route.
Selection
max(p) among matchesLonger prefixes are more specific.
Default route
0.0.0.0/0 matches every DThe fallback with p = 0.
Worked example: destination 10.1.2.77
0.0.0.0/0 ✓ match (p = 0) 10.0.0.0/8 ✓ match (p = 8) 10.1.0.0/16 ✓ match (p = 16) 10.1.2.0/24 ✓ match (p = 24) 10.1.2.128/25 ✗ (77 < 128) Best = 10.1.2.0/24
Longest Prefix Match Calculator Conversion Table
The table resolves 10 destination addresses against a 6-route table (0.0.0.0/0, 10.0.0.0/8, 10.1.0.0/16, 10.1.2.0/24, 10.1.2.128/25, 10.1.2.200/32).
| Destination | Matching Routes | Selected Route | Prefix Length |
|---|---|---|---|
| 10.1.2.77 | 4 | 10.1.2.0/24 | /24 |
| 10.1.2.130 | 5 | 10.1.2.128/25 | /25 |
| 10.1.2.200 | 6 | 10.1.2.200/32 | /32 |
| 10.1.2.201 | 5 | 10.1.2.128/25 | /25 |
| 10.1.3.5 | 3 | 10.1.0.0/16 | /16 |
| 10.2.0.1 | 2 | 10.0.0.0/8 | /8 |
| 10.255.255.255 | 2 | 10.0.0.0/8 | /8 |
| 11.0.0.1 | 1 | 0.0.0.0/0 | /0 |
| 192.168.1.1 | 1 | 0.0.0.0/0 | /0 |
| 10.1.2.255 | 5 | 10.1.2.128/25 | /25 |
What is Longest Prefix Match Calculator?
The Longest Prefix Match Calculator is a tool that finds which route a router selects for a destination address, using the longest prefix match rule.
Routers often hold several routes that cover the same destination. RFC 1812 requires the router to pick the most specific one, the route with the most network bits. A /32 beats a /25, a /25 beats a /24, and every specific route beats the /0 default route.
Longest prefix match decides the next hop before administrative distance and metrics apply between routes of equal length. The calculator shows the full candidate list, which explains why traffic takes a given path.
What are the uses of Longest Prefix Match Calculator?
There are 4 main uses of the Longest Prefix Match Calculator, including path troubleshooting, change validation, and traffic engineering.
Troubleshooting unexpected paths
A more-specific route learned from a VPN often overrides a summary. The calculator shows which route wins.
Validating route changes
Before adding a route, engineers test which destinations move to the new path.
Designing traffic engineering
More-specific announcements pull traffic toward a preferred link. The calculator previews the effect.
Teaching routing decisions
Students see every match and the selected route for each destination.