IPv4 subnetting
Convert prefix lengths and masks, find network, broadcast and usable ranges, and handle /31 and /32 boundary cases correctly.
The subnetting method
The interesting octet's step size, e.g. mask .192 → block of 64.
Subtract network and broadcast — except /31 links and /32 hosts.
First address of the block; not assignable on normal subnets.
Last address of the block; not assignable.
Subnetting needs three numbers: the block size in the interesting octet, the network address (nearest multiple of the block size at or below the host octet), and the broadcast (network + block − 1). Everything else — first host, last host, host count — falls out of those three.
Prefix lengths, masks, wildcards and block sizes
| Prefix | Dotted mask | Wildcard | Addresses per block | Theoretical host slots* |
|---|---|---|---|---|
| /0 | 0.0.0.0 | 255.255.255.255 | 4294967296 | 4294967294 |
| /1 | 128.0.0.0 | 127.255.255.255 | 2147483648 | 2147483646 |
| /2 | 192.0.0.0 | 63.255.255.255 | 1073741824 | 1073741822 |
| /3 | 224.0.0.0 | 31.255.255.255 | 536870912 | 536870910 |
| /4 | 240.0.0.0 | 15.255.255.255 | 268435456 | 268435454 |
| /5 | 248.0.0.0 | 7.255.255.255 | 134217728 | 134217726 |
| /6 | 252.0.0.0 | 3.255.255.255 | 67108864 | 67108862 |
| /7 | 254.0.0.0 | 1.255.255.255 | 33554432 | 33554430 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16777216 | 16777214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8388608 | 8388606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4194304 | 4194302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2097152 | 2097150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1048576 | 1048574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524288 | 524286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262144 | 262142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131072 | 131070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65536 | 65534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32768 | 32766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16384 | 16382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8192 | 8190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4096 | 4094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2048 | 2046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1024 | 1022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (point-to-point only) |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (host route) |
Binary arithmetic, not globally allocatable host counts — reserved ranges and addressing policy still apply. /0 is normally the default route, /31 is point-to-point only (RFC 3021), /32 is a single host route.
- Address
- 192.168.1.77
- Prefix
- /26
- Mask: /26 → 255.255.255.192. Interesting octet is the 4th.
- Block size: 256 − 192 = 64 → subnet boundaries at .0, .64, .128, .192.
- 77 falls in the .64–.127 block → network 192.168.1.64, broadcast 192.168.1.127.
- Usable range: 192.168.1.65 – 192.168.1.126 → 62 usable hosts.
192.168.1.77/26 lives in 192.168.1.64/26, usable .65–.126, broadcast .127.
/31, /32 and wildcards
/31 is a special case defined by RFC 3021 for point-to-point links: with only two addresses, both are usable endpoints and there is no network/broadcast reservation — it saves space on router-to-router links. /32 identifies exactly one host; it appears as host routes and loopbacks. Applying 'minus 2' blindly to these prefixes gives −1 or wrong answers.
Wildcard masks are the bitwise inverse of a subnet mask: subtract each mask octet from 255. A /26 network uses mask 255.255.255.192 and wildcard 0.0.0.63; /24 uses wildcard 0.0.0.255; a single host is wildcard 0.0.0.0. Zero wildcard bits must match exactly; one bits are ignored — the same logic ACLs and OSPF network statements use.
Verification and mistakes
Confirm interface addresses land on the intended subnet — Privileged EXEC
Cisco IOS / IOS XE
show ip interface brief show ip interface gi0/1 ping <neighbor-ip>
- Configured mask matches the intended prefix.
- Neighbors in the same subnet ping; neighbors outside it route via a gateway.
Read-only verification commands.
Common mistakes
- Subtracting 2 from every prefix — /31 and /32 have different rules.
- Mixing up mask and wildcard — a /26 is 255.255.255.192 but wildcard 0.0.0.63.
- Counting the network or broadcast address as usable host IPs on normal subnets.
- Computing the network by rounding to the nearest .0 boundary of the wrong block size — always derive block size from the mask first.
Observation: Host A 10.1.1.70/26 and Host B 10.1.1.140/26 cannot ping each other directly.
- They are in different subnets despite similar addresses
- Missing gateway configuration
- ACL blocking traffic
| Check | Indicates |
|---|---|
| Recompute each subnet | /26 blocks are .0/.64/.128/.192 — .70 is in .64–.127, .140 is in .128–.191: different subnets. |
| Gateway addresses on each host | Each needs a gateway inside its own block to route between subnets. |
Correction: Put both hosts in the same subnet or route between them via a router interface in each subnet.
Traffic flows — via the gateway when subnets differ, directly when they match.
Related resources
Sources
- Cisco CCNA 200-301 v1.1 Exam Topics (official PDF) — reviewed 2026-11-02
- RFC 3021 — Using 31-Bit Prefixes on IPv4 Point-to-Point Links — reviewed 2026-11-02
- RFC 4632 — Classless Inter-domain Routing (CIDR) — reviewed 2026-11-02
- Cisco — IP Addressing Services Command Reference — reviewed 2026-11-02
Targets CCNA 200-301 v1.1 objectives. Supplemental blocks are labeled beyond exam scope.