Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

Prefix length

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

When to use this

Use it when choosing between routes, writing summaries, or reading why a more specific route wins.

First 30 seconds

1. show ip route <dst> — which prefix matched, from which source?

2. More specific than expected → longer-prefixes on the expected block: who injects it?

3. Less specific than expected (summary or default) → the specific route is missing.

4. show ip cef <dst> — does forwarding agree?

5. Fix the source of the unwanted or missing route, not the metric.

Operational verification

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

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Cisco IOS / IOS XE
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCisco IOS / IOS XE · Cisco IOS XE · IOS/IOS XE
Scope / prerequisiteUse it when choosing between routes, writing summaries, or reading why a more specific route wins.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Troubleshooting prefix-length problems Narrow the fault
SymptomCommandLook forNext check
Traffic uses an unexpected routeshow ip route 10.1.1.5"Routing entry for 10.1.1.0/24" — the prefix actually selectedWhere that more specific route comes from
Overlapping routesshow ip route 10.1.0.0 255.255.0.0 longer-prefixesEvery more-specific route inside the rangeRemove or filter the unwanted specific route
FIB disagreesshow ip cef 10.1.1.5Same prefix and next hop as the RIBAdjacency and next-hop resolution
Wrong mask on an interfaceshow ip interface brief / show running-config interface <if>Intended address and maskConnected route length in show ip route connected
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key 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.
ReferenceHow it works1 section · depth on demand

Mechanics and state boundaries

The prefix length (/n) says how many leading bits identify the network. During a route lookup the router considers every route that contains the destination and uses the one with the longest prefix (most specific).

Example routing table: 10.0.0.0/8 (OSPF), 10.1.0.0/16 (static), 10.1.1.0/24 (EIGRP).

  • 10.1.1.5 uses 10.1.1.0/24.
  • 10.1.2.5 uses 10.1.0.0/16.
  • 10.9.9.9 uses 10.0.0.0/8.

Administrative distance and metric are compared only between routes with the same prefix and length. Host routes are /32 (IPv4) and /128 (IPv6); a summary is a shorter prefix that a more specific route always overrides.

When to use it: Read prefix length when traffic follows an unexpected route, a summary does not attract traffic, or a mask is wrong on an interface or a static route.

ReferenceImportant terms & boundaries2 sections · depth on demand

In depth

Prefix length: how specific a route is

The prefix length (the /n) counts the network bits. Longer means more specific: a /24 is more specific than a /16 that contains it. RFC 1812 requires routers to forward using the most specific matching route, so when several routes contain a destination, the one with the longest prefix length wins, regardless of protocol or metric.

Mask and length

LengthMaskAddressesTypical use
/8255.0.0.016 777 216Large private block
/16255.255.0.065 536Site summary
/24255.255.255.0256Access VLAN
/30255.255.255.2524Point-to-point link
/31255.255.255.2542Point-to-point (RFC 3021)
/32255.255.255.2551Loopback, host route

One destination, several routes

RouteSourceLengthChosen for 10.20.30.77?
0.0.0.0/0Static0No
10.0.0.0/8eBGP8No
10.20.0.0/16OSPF16No
10.20.30.0/24EIGRP24Yes: longest match
R1# show ip route 10.20.30.77
Routing entry for 10.20.30.0/24
  Known via "eigrp 100", distance 90, metric 3072, type internal
R1# show ip route summary
IP routing table name is default (0x0)
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           6           0           576         1824
static          1           3           0           384         1216
ospf 1          0           14          0           1344        4256

Prefix lengths and hardware

On Catalyst 9000 switches, /32 entries use exact-match memory and shorter prefixes use longest-prefix-match memory (Cisco hardware resources technote); many different mask lengths in one design use hardware less efficiently.

Design practice

Use consistent lengths (for example /24 per VLAN, /31 or /30 per link, /32 per loopback) and summarise at boundaries so other areas see short prefixes.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Quick reference

The prefix length is the first thing a router compares when several routes match a destination: the most specific one always wins, before administrative distance or metric are even considered. This makes specific routes powerful — useful for exceptions, dangerous when they are forgotten or leaked by mistake.

Prefix length determines specificity: a /28 route is preferred over a /24 that also contains the destination, regardless of AD or metric.

show ip route 10.0.20.77 longer-prefixes
show ip route 10.0.20.77           ! shows the best matching entry

This is why a stray specific route (static /32, leaked host route) can silently override the expected path — always check for more specific entries when traffic goes the wrong way.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCisco IOS / IOS XE Current documentation reviewed 2026-09-14

Authoritative/upstream documentation reviewed for bounded claims in Routing → Routing Table → Prefix length. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.cisco.com/c/en/us/support/ios-nx-os-software/ios-xe-17/series.html · confidence 94%
Confirmation

Confirm action

Continue?