longest prefix match
The rule that when several routes match a destination, the one with the longest prefix, the most specific, wins.
In more detail
A /24 route beats a /16, and anything beats the /0 default route. This lets a host send local traffic directly while everything else goes to the gateway.
Example
In AWS: The routing rule that, when several routes match a destination, the one with the smallest range wins.Related terms
- route table — A list of destinations and next hops that decides where packets leaving a subnet go.
- CIDR — A compact way to write a range of IP addresses, such as 10.244.0.0/24, where the number after the slash says how many leading bits are fixed.
- default route — The route used for any destination that no more specific route matches, written 0.0.0.0/0 or shown as default.
- routing table — The kernel's list of destination prefixes and where to send packets for each: out of which interface and through which next hop.
- prefix length — The number after the slash in an address such as 192.0.2.42/24, saying how many leading bits identify the network.
Taught in
- Route Tables and Internet Gateways — Cloud Infrastructure & Hyperscaler Architecture
- Cloud Network Isolation: VPC Peering & PrivateLink — Cloud Security & DevSecOps Engineering
- Interfaces, Routes And The Default Gateway — Linux Fundamentals & Systems Administration