Determine the next-hop gateway for a destination based on the routing table entries.
When multiple routes in a routing table could carry traffic to the same destination, routers always select the route with the longest (most specific) matching prefix, regardless of administrative distance or metric — that comparison only happens between routes of equal prefix length. This calculator checks the destination IP against every entry in the supplied table, keeps every route whose network/prefix covers that address, and reports the one with the longest prefix as the actual route the router would use.
Longest prefix match rule
select the matching route with the greatest prefix length
Longest prefix match is the rule that when a destination address matches multiple routes of different specificity, the router always chooses the most specific (longest prefix) one, because a longer prefix describes a smaller, more precisely targeted network and is assumed to be the more accurate path for that destination.
No — the default route has the shortest possible prefix (/0) and will only be selected when no other, more specific route matches the destination at all. It exists purely as a catch-all fallback for traffic to destinations not explicitly known.
Administrative distance is only used to choose between multiple routes to the exact same destination prefix learned from different sources (e.g. both OSPF and static). It never overrides longest prefix match — a router will always prefer a more specific /24 route over a less specific /16 route to the same address, even if the /16 came from a lower-AD source.