Visual RFC.
ALL RFCs / RFC 4632
Read the RFC ↗
RFC 4632 / CIDR

Choose the longest match

03

A forwarding table can contain several prefixes that include the same destination. Longest-prefix matching chooses the matching route with the most fixed leading bits.

RFC 4632 · § 5.1EXAMPLE
4 / 4
Choose the longest matchSeparate default export decision: implementation support remains required, but absent explicit export configuration blocks /0 announcement before the neighbor.Most-specific matching prefix winsLocal routerNeighborDefault /0 support: MUSTLocal default use ≠ default exportExplicit export configured? NOstop /0 exportNo default announcement reaches neighborSame-prefix best-path selection is separate
04
Gate default-route export

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 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
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.

Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

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.
DETAILS

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 ↗

All chapters in RFC 4632

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗