Choose the longest match
03A forwarding table can contain several prefixes that include the same destination. Longest-prefix matching chooses the matching route with the most fixed leading bits.
Separate control-plane decision: this neighbor has no explicit default advertisement configured. Stop /0 at the export gate. Supporting or using a default locally is not permission to advertise it.
Source for this drawing: RFC 4632 · Read RFC section 5.1 ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
First find the most-specific matching prefix; a shorter route’s metric does not override it.
- §5.1 Rule 1 forwards using the longest matching prefix. A matching /25 is more specific than /24; a /24 is more specific than /0. This is destination-prefix selection, not the complete process for learning or choosing between routes to the same prefix.
- For 192.0.2.200, both 192.0.2.0/24 and 192.0.2.128/25 match, so /25 wins. For 192.0.2.20, that /25 does not match, so /24 wins. For 198.51.100.9, neither matches; a configured /0 may supply a default.
- Implementations MUST accept the 0.0.0.0/0 prefix (§5.1). That support requirement does not instruct an operator to originate or export a default route to every neighbor.
- §5.1 says default routes should only be advertised to another domain when explicitly configured and never by an unconfigured default. The final gate shows an absent configuration preventing export; it does not remove /0 implementation support.
- Prefix lengths and left-contiguous masks must be explicit. Filtering also needs an explicit prefix and mask (§5.3): matching exactly /24 and permitting all its more-specific prefixes are different policies, not interchangeable shortcuts.
Fictional next hops A, B and D. A bounded teaching table, not a BGP best-path algorithm or a real router configuration.
Read the RFC section ↗