Subnet mask cheat sheet: every CIDR prefix, mask and host count
One page to keep open while you plan a network or study for an exam: the full CIDR chart, the eight mask values worth memorizing, the block-size shortcut for subnetting by hand, and the address ranges that are reserved.
Subnet masks and CIDR in one minute
An IPv4 address is 32 bits, written as four numbers from 0 to 255 (octets). A subnet mask marks which of those bits name the network and which name a host inside it: every 1 bit in the mask is network, every 0 bit is host. 255.255.255.0 is 24 ones followed by 8 zeros, so the first three octets are the network and the last one is the host.
CIDR notation (Classless Inter-Domain Routing) writes the same thing as a slash and the number of 1 bits: 192.168.1.0/24 means the mask 255.255.255.0. The prefix length is the only number you need; the mask, the wildcard mask and the host count all follow from it. CIDR is defined in RFC 4632, and the original subnetting procedure in RFC 950.
Every subnet has a network address (all host bits 0) and a broadcast address (all host bits 1). Neither can be given to a device, which is why a subnet with 256 addresses has 254 usable hosts.
CIDR chart: /0 to /32
Usable hosts are the total addresses minus 2 (network and broadcast), except /31 and /32. The wildcard mask is the mask inverted (255 minus each octet); Cisco ACLs and OSPF use it instead of the subnet mask.
| Prefix | Subnet mask | Wildcard mask | Addresses | Usable hosts |
|---|---|---|---|---|
| /0 | 0.0.0.0 | 255.255.255.255 | 4,294,967,296 | n/a (default route) |
| /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 (point-to-point links, RFC 3021) |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (a single host) |
The eight mask values to memorize
A mask octet can only take nine values: 0 and the eight below. Each adds one more 1 bit from the left. The block size is 256 minus the value, and it is the step between one subnet and the next in that octet.
| Mask octet | Binary | Block size | Prefix in 4th / 3rd / 2nd octet |
|---|---|---|---|
128 | 10000000 | 128 | /25 · /17 · /9 |
192 | 11000000 | 64 | /26 · /18 · /10 |
224 | 11100000 | 32 | /27 · /19 · /11 |
240 | 11110000 | 16 | /28 · /20 · /12 |
248 | 11111000 | 8 | /29 · /21 · /13 |
252 | 11111100 | 4 | /30 · /22 · /14 |
254 | 11111110 | 2 | /31 · /23 · /15 |
255 | 11111111 | 1 | /32 · /24 · /16 |
If you remember the powers of two (2, 4, 8, 16, 32, 64, 128, 256), you can rebuild this table in your head: a /24 has 2^8 = 256 addresses, and each extra prefix bit halves the subnet.
Subnetting by hand: the block-size method
To find the network, broadcast and host range for any address and prefix:
- Find the interesting octet: the one where the mask is neither 255 nor 0.
- Work out the block size: 256 minus the mask value in that octet.
- List multiples of the block size (0, block, 2 × block …) and find the one at or just below the address's value in that octet. That is the network address.
- The next multiple minus 1 is the broadcast address. Everything between them is the usable host range.
Example 1: 192.168.10.77/27. The mask is 255.255.255.224, so the interesting octet is the fourth and the block size is 256 − 224 = 32. The subnets start at 0, 32, 64, 96 …; 77 falls between 64 and 95.
| Field | Value |
|---|---|
| Network address | 192.168.10.64 |
| First usable host | 192.168.10.65 |
| Last usable host | 192.168.10.94 |
| Broadcast address | 192.168.10.95 |
| Usable hosts | 30 |
Example 2: 10.20.37.5/20. The mask is 255.255.240.0, so the interesting octet is the third and the block size is 16. The subnets start at 0, 16, 32, 48 …; 37 falls between 32 and 47. The network is 10.20.32.0, the broadcast is 10.20.47.255, and hosts run from 10.20.32.1 to 10.20.47.254 (4,094 usable).
To check your work, or to skip the arithmetic, paste the address into the subnet calculator. It shows the network, broadcast, mask, wildcard and host range for any IPv4 CIDR block.
Splitting a /24 into smaller subnets
Each bit you borrow from the host part doubles the number of subnets and halves their size. Starting from one /24 (256 addresses):
| New prefix | Subnets | Addresses each | Usable hosts each | Subnets start at (4th octet) |
|---|---|---|---|---|
| /25 | 2 | 128 | 126 | 0, 128 |
| /26 | 4 | 64 | 62 | 0, 64, 128, 192 |
| /27 | 8 | 32 | 30 | 0, 32, 64 … 224 |
| /28 | 16 | 16 | 14 | 0, 16, 32 … 240 |
| /29 | 32 | 8 | 6 | 0, 8, 16 … 248 |
| /30 | 64 | 4 | 2 | 0, 4, 8 … 252 |
To size a subnet, take the number of hosts you need, add 2, and round up to the next power of two. 50 devices need 52 addresses, so a /26 (64) fits; 100 devices need a /25. Leave room to grow, because renumbering a subnet later is much harder than starting one size larger.
Where each size is used
| Prefix | Typical use |
|---|---|
| /32 | One address: a host route, a loopback interface, or a single IP in a firewall rule |
| /31 | A link between two routers, with no network or broadcast address wasted (RFC 3021) |
| /30 | The older way to number a point-to-point link: 2 usable addresses |
| /29 | A small block of public IPs from an ISP: 6 usable, one of which is usually the gateway |
| /24 | The usual office or home LAN, such as 192.168.1.0/24 |
| /22 – /20 | Larger LANs, campus VLANs and Wi-Fi networks with many clients |
| /16 | A whole site or a cloud virtual network, split into smaller subnets inside |
RFC 3021 allows a /31 on point-to-point links because there are only two ends, so neither address needs to be the network or broadcast. Most current router operating systems support it.
Private and reserved IPv4 ranges
| Range | CIDR | What it is |
|---|---|---|
10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | Private (RFC 1918) |
172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | Private (RFC 1918) |
192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | Private (RFC 1918) |
100.64.0.0 – 100.127.255.255 | 100.64.0.0/10 | Shared address space for carrier-grade NAT (RFC 6598) |
127.0.0.0 – 127.255.255.255 | 127.0.0.0/8 | Loopback: traffic never leaves the host |
169.254.0.0 – 169.254.255.255 | 169.254.0.0/16 | Link-local: self-assigned when DHCP fails |
The three private blocks in RFC 1918 are not routed on the public internet, so any network can reuse them behind NAT. RFC 6598 set aside 100.64.0.0/10 for ISPs that run carrier-grade NAT; if your router's WAN address is in that range, you do not have a public IP of your own. The What is my IP tool shows the public address the internet actually sees.
IP address classes (and why they no longer matter)
Before CIDR, the first bits of an address fixed its network size. You will still meet these classes in exam questions and old documentation:
| Class | First octet | Default mask | Purpose |
|---|---|---|---|
| A | 1 – 126 | 255.0.0.0 (/8) | Large networks (127 is reserved for loopback) |
| B | 128 – 191 | 255.255.0.0 (/16) | Medium networks |
| C | 192 – 223 | 255.255.255.0 (/24) | Small networks |
| D | 224 – 239 | None | Multicast |
| E | 240 – 255 | None | Reserved, experimental |
CIDR replaced this scheme in 1993 because fixed /8, /16 and /24 blocks wasted addresses and bloated routing tables. Today any prefix length can be used anywhere, so 10.1.2.0/24 and 192.168.0.0/22 are both perfectly normal.
A note on IPv6
IPv6 has no subnet masks in dotted form, only prefix lengths, and the sizes work differently: a normal LAN is a /64, and a site is commonly given a /48 or /56 to split into /64s. There is no broadcast address in IPv6, so nothing is subtracted from the host count. The cheat sheet above is for IPv4 only.
Frequently asked questions
How do I check a subnet range?
Take the block size (256 minus the mask value in the octet that is not 255 or 0), find the multiple of it at or below your address, and that is the network address; the next multiple minus 1 is the broadcast. A subnet calculator does the same instantly for any CIDR block.
What are the 5 classes of IP addresses?
Class A (first octet 1–126, default /8), class B (128–191, /16), class C (192–223, /24), class D (224–239, multicast) and class E (240–255, reserved). Classes have been obsolete for routing since CIDR in 1993, but they still appear in exams and old documentation.
What is a subnet mask, in simple terms?
A subnet mask tells a device which part of an IP address is the network and which part is the device itself. With 255.255.255.0, addresses that share the first three numbers are on the same local network and are reached directly; anything else goes through the router.
What does a subnet mask of 255.255.255.255 do?
255.255.255.255 is a /32: all 32 bits are network bits, so the subnet holds exactly one address. It is used for host routes, loopback interfaces, VPN tunnel endpoints and firewall rules that match a single IP.
What happens if I use the wrong subnet mask?
If the mask is too small, the device thinks some local addresses are remote and sends that traffic to the router, which can fail or slow things down. If it is too large, the device tries to reach remote addresses directly on the LAN and cannot. Either way, some hosts become unreachable.
How many usable hosts are in a /24, /27 or /30?
A /24 has 254 usable hosts, a /27 has 30 and a /30 has 2. The rule is 2 to the power of (32 minus the prefix), minus 2 for the network and broadcast addresses. /31 and /32 are exceptions with 2 and 1 usable addresses.
What is the difference between a subnet mask and a wildcard mask?
A wildcard mask is the subnet mask inverted: 255 minus each octet, so 255.255.255.0 becomes 0.0.0.255. Subnet masks configure interfaces; wildcard masks are used in Cisco access lists and OSPF to say which bits of an address to ignore.
Sources
Free tools for this
More guides
- SSL Handshake Failed: What It Means and How to Fix It
- Unable to Get Local Issuer Certificate: Causes and Fixes
- What Is DKIM? How DKIM Records Work and How to Set One Up
- Domain Expired? What Happens Next: Grace & Redemption
- Your Connection Is Not Private: How Site Owners Fix It
- How to Renew an SSL Certificate (and Catch Failed Renewals)