Subnet cheat sheet
Every IPv4 prefix length with its subnet mask, wildcard mask and host count. Select a prefix for worked examples, or use the subnet calculator for a specific address.
IPv4 CIDR to subnet mask
| Prefix | Subnet mask | Wildcard mask | Addresses | Usable hosts |
|---|---|---|---|---|
| /0 | 0.0.0.0 | 255.255.255.255 | 4,294,967,296 | 4,294,967,294 |
| /1 | 128.0.0.0 | 127.255.255.255 | 2,147,483,648 | 2,147,483,646 |
| /2 | 192.0.0.0 | 63.255.255.255 | 1,073,741,824 | 1,073,741,822 |
| /3 | 224.0.0.0 | 31.255.255.255 | 536,870,912 | 536,870,910 |
| /4 | 240.0.0.0 | 15.255.255.255 | 268,435,456 | 268,435,454 |
| /5 | 248.0.0.0 | 7.255.255.255 | 134,217,728 | 134,217,726 |
| /6 | 252.0.0.0 | 3.255.255.255 | 67,108,864 | 67,108,862 |
| /7 | 254.0.0.0 | 1.255.255.255 | 33,554,432 | 33,554,430 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /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 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
Usable hosts subtracts the network and broadcast addresses. A /31 has both addresses usable on point-to-point links (RFC 3021) and a /32 is a single address.
Common IPv6 prefix sizes
| Prefix | Addresses | /64 subnets |
|---|---|---|
| /32 | 2^96 | 4,294,967,296 |
| /48 | 2^80 | 65,536 |
| /56 | 2^72 | 256 |
| /64 | 18,446,744,073,709,551,616 | 1 |
| /127 | 2 | — |
| /128 | 1 | — |
IPv6 has no broadcast address, so almost every address in a block can be assigned (each /64 reserves its Subnet-Router anycast address and 128 anycast IDs). A /64 is the standard size of one LAN.
Cloud subnet limits
Cloud networks reserve some addresses in every subnet for the router, DNS and the provider's own use, and limit which sizes you can create.
| Provider | Reserved per subnet | Smallest subnet | Source |
|---|---|---|---|
| AWS VPC | 5 | /28 | Documentation |
| Azure Virtual Network | 5 | /29 | Documentation |
| Google Cloud VPC | 4 | /29 | Documentation |
Questions
What does the number after the slash mean?
It is the prefix length: how many leading bits of the address identify the network. The remaining bits identify hosts inside it. 10.0.0.0/8 fixes the first 8 bits, so every address from 10.0.0.0 to 10.255.255.255 is in the block.
How do I convert a subnet mask to CIDR?
Count the 1 bits in the mask. Each 255 octet is 8 bits, so 255.255.255.0 is 24 bits and the CIDR form is /24. For a partial octet, use the table: 255.255.255.192 is /26 and 255.255.240.0 is /20.
Why is usable hosts two less than total addresses?
In an IPv4 subnet the first address names the network itself and the last is the broadcast address, so neither is given to a host. The exceptions are /31, where RFC 3021 lets both addresses be used on a point-to-point link, and /32, which is one address.
Which subnet size should I use for a home or office network?
A /24 holds 254 hosts and suits most home and small office networks. Use a smaller prefix such as /23 or /22 when you need more devices on one network, and longer prefixes such as /29 or /30 for small segments like links between routers.