Reference · works without JavaScript
Subnet mask to CIDR cheat sheet.
Every IPv4 prefix from /0 to /32 with its subnet mask, wildcard mask, total addresses and usable host count — a subnet mask to CIDR calculator that needs no JavaScript. Hover any row to copy a value.
| Prefix | Subnet mask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /0 | 4,294,967,296 | 4,294,967,294 | ||
| /1 | 2,147,483,648 | 2,147,483,646 | ||
| /2 | 1,073,741,824 | 1,073,741,822 | ||
| /3 | 536,870,912 | 536,870,910 | ||
| /4 | 268,435,456 | 268,435,454 | ||
| /5 | 134,217,728 | 134,217,726 | ||
| /6 | 67,108,864 | 67,108,862 | ||
| /7 | 33,554,432 | 33,554,430 | ||
| /8 | 16,777,216 | 16,777,214 | ||
| /9 | 8,388,608 | 8,388,606 | ||
| /10 | 4,194,304 | 4,194,302 | ||
| /11 | 2,097,152 | 2,097,150 | ||
| /12 | 1,048,576 | 1,048,574 | ||
| /13 | 524,288 | 524,286 | ||
| /14 | 262,144 | 262,142 | ||
| /15 | 131,072 | 131,070 | ||
| /16 | 65,536 | 65,534 | ||
| /17 | 32,768 | 32,766 | ||
| /18 | 16,384 | 16,382 | ||
| /19 | 8,192 | 8,190 | ||
| /20 | 4,096 | 4,094 | ||
| /21 | 2,048 | 2,046 | ||
| /22 | 1,024 | 1,022 | ||
| /23 | 512 | 510 | ||
| /24 | 256 | 254 | ||
| /25 | 128 | 126 | ||
| /26 | 64 | 62 | ||
| /27 | 32 | 30 | ||
| /28 | 16 | 14 | ||
| /29 | 8 | 6 | ||
| /30 | 4 | 2 | ||
| /31 | 2 | 2 | ||
| /32 | 1 | 1 |
Common IPv6 prefixes
IPv6 prefixes are not usually chosen to fit a host count — they are chosen to sit on a recognisable boundary. These are the ones that show up in practice.
| Prefix | Addresses | Typical use |
|---|---|---|
| /32 | 2^96 | ISP or regional allocation |
| /40 | 2^88 | Large customer delegation |
| /48 | 2^80 | One site — 65,536 /64 subnets |
| /56 | 2^72 | Residential delegation — 256 /64s |
| /60 | 2^68 | 16 /64 subnets |
| /64 | 2^64 | One subnet — the SLAAC boundary |
| /112 | 2^16 | Sometimes used for infrastructure links |
| /126 | 4 | Point-to-point, IPv4-style |
| /127 | 2 | Point-to-point per RFC 6164 |
| /128 | 1 | A single host route |
Mask octet values
Only nine values can ever appear in a valid IPv4 mask octet. Recognising them is most of what subnetting by hand requires.
0
0 bits
128
1 bit
192
2 bits
224
3 bits
240
4 bits
248
5 bits
252
6 bits
254
7 bits
255
8 bits
Questions people actually ask
How do I convert a subnet mask to a prefix length?
Count the one-bits in the mask. 255.255.255.0 is three full octets of ones plus an empty one, so 8 + 8 + 8 = /24. The only octet values that appear in a valid mask are 0, 128, 192, 224, 240, 248, 252, 254 and 255, contributing 0 through 8 bits respectively.
What is a wildcard mask for?
It is the bitwise inverse of the subnet mask, and Cisco ACLs and OSPF network statements use it instead of a netmask. A /24 has mask 255.255.255.0 and wildcard 0.0.0.255. A zero bit in a wildcard means "must match", a one bit means "ignore".
Why does /31 show 2 usable hosts and not 0?
RFC 3021 permits a /31 on point-to-point links, where there is no need for a broadcast address because there is exactly one other device. Both addresses are assigned. Older equipment may not support it, in which case a /30 with two usable addresses out of four is the fallback.
Which prefix do I need for N hosts?
Find the smallest power of two that is at least N + 2, then subtract its exponent from 32. For 500 hosts you need 512 addresses, which is 2^9, so 32 − 9 = /23. Remember the +2 for the network and broadcast addresses — 254 hosts fit in a /24, but 255 hosts need a /23.