Use it when choosing between routes, writing summaries, or reading why a more specific route wins.
Prefix length
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.
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.
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Troubleshooting prefix-length problems Narrow the fault
| Symptom | Command | Look for | Next check |
|---|---|---|---|
| Traffic uses an unexpected route | show ip route 10.1.1.5 | "Routing entry for 10.1.1.0/24" — the prefix actually selected | Where that more specific route comes from |
| Overlapping routes | show ip route 10.1.0.0 255.255.0.0 longer-prefixes | Every more-specific route inside the range | Remove or filter the unwanted specific route |
| FIB disagrees | show ip cef 10.1.1.5 | Same prefix and next hop as the RIB | Adjacency and next-hop resolution |
| Wrong mask on an interface | show ip interface brief / show running-config interface <if> | Intended address and mask | Connected route length in show ip route connected |
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.
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.
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
| Length | Mask | Addresses | Typical use |
|---|---|---|---|
| /8 | 255.0.0.0 | 16 777 216 | Large private block |
| /16 | 255.255.0.0 | 65 536 | Site summary |
| /24 | 255.255.255.0 | 256 | Access VLAN |
| /30 | 255.255.255.252 | 4 | Point-to-point link |
| /31 | 255.255.255.254 | 2 | Point-to-point (RFC 3021) |
| /32 | 255.255.255.255 | 1 | Loopback, host route |
One destination, several routes
| Route | Source | Length | Chosen for 10.20.30.77? |
|---|---|---|---|
| 0.0.0.0/0 | Static | 0 | No |
| 10.0.0.0/8 | eBGP | 8 | No |
| 10.20.0.0/16 | OSPF | 16 | No |
| 10.20.30.0/24 | EIGRP | 24 | Yes: 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.
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.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%