Longest Prefix Match aka Maximum prefix length match
In case a router (or host) wants to forward an IP packet to its destination IP address and this address matches with multiple entries in the routing table from the router, the most specific table entry with the longest subnet mask will be used for.
This is called longest prefix match
For example, consider this IPv4 forwarding table (CIDR notation is used):
When the address 192.168.20.19 needs to be looked up, both entries in the forwarding table “match”. That is, both entries contain the looked up address. In this case, the longest prefix of the candidate routes is 192.168.20.16/28, since its subnet mask (/28) is longer than the other entry’s mask (/16), making the route more specific.
Forwarding tables often contain a default route, which has the shortest possible prefix match, to fall back on in case matches with all other entries fail.
Specify the static route on the device to resolve and determine the packet’s next-hop interface using the Longest Match Routing Rule (most specific entry), sometimes referred to as the longest prefix match or maximum prefix length match. The Longest Match Routing Rule is an algorithm used by IP routers to select an entry from a routing table. The router uses the longest (prefix) match to determine the egress (outbound) interface and the address of the next device to which to send a packet. Typically, the static route prefers the directly connected subnet route for resolving the next hop rather than performing a longest prefix match with any other available routes.
Longest prefix match
longest-match (Static Routes)
Longest Prefix Matching in Routers
Guidelines for Numbering IPv6 Point-to-Point Links and Easing the Addressing Plans