Pcornel
Networking · Routing › Routing Table

Prefix length

Cheat sheet · https://pcornel.dk/topic.php?topic=1063

Back to the Topic

Answer

The prefix length is the number of leading bits a destination must share with a route for the route to match: /32 is one address, /24 is 256, /0 is everything.

Remember

Longer prefix = more specific = preferred. The router always prefers the longest match before looking at distance or metric. A /0 default route is used only when nothing else matches.

First checks

  • show ip route <dst> — the route actually chosen for that address.
  • show ip route <prefix> <mask> longer-prefixes — every more specific route under a block.
  • show ip cef <dst> — the forwarding entry used.
  • show ipv6 route <dst> — the same for IPv6.

Commands

show ip route 10.1.1.5
show ip route 10.1.0.0 255.255.0.0 longer-prefixes
show ip cef 10.1.1.5
show ip interface brief
show running-config interface <if>
show ip route connected

Verify in this order

destination address → all routes that contain it → the longest prefix selected → its next hop resolved → CEF entry matches

Where it usually breaks

underlay/interface reachability → protocol adjacency/session → received/originated state → policy → best path/RIB → FIB/adjacency → traffic path

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=1063

Confirmation

Confirm action

Continue?