A Subnetting Cheat Sheet With Worked Examples
Keep every prefix, mask, block size and host count on one page, with step-by-step examples and quick checks for IPv4 and IPv6.
Key takeaways
- The block size in the partial octet is 256 minus the mask value in that octet.
- Total addresses equal 2 to the power of (32 minus the prefix), and ordinary subnets lose two of them.
- The network address is the block's start, and the broadcast is one before the next block.
- Hosts, routes and rules all follow the same boundaries, so one method answers nearly every question.
This page gives you the tables you need to answer subnet questions quickly, followed by worked examples that show how to use them. The one procedure to remember: find the octet where the mask is partial, get the block size, and locate the multiple of that size at or below your address.
If any term here is new, read subnetting explained from the ground up first. Otherwise, bookmark and reuse.
The master table
| Prefix | Mask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /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) |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (single host) |
The wildcard column is the inverse form used in some access lists, explained in wildcard masks.
Basis: IPv4 prefix arithmetic (RFC 4632).
Reading the table
Addresses is the size of the block as a route or firewall rule sees it. Usable hosts is what you can assign to interfaces on an ordinary subnet, after removing the network address at the bottom and the broadcast address at the top. The router's own interface comes out of the usable figure too.
Two rows behave differently. A /31 is meant for a link with exactly two ends, where RFC 3021 lets both addresses be assigned. A /32 names a single address and appears in host routes, loopback interfaces and rules for one machine.
Moving one row down halves the block. Moving one row up doubles it. If you remember that a /24 holds 256 addresses, you can walk to any other row: /23 is 512, /22 is 1,024, /25 is 128 and so on. The slash itself is explained in CIDR notation.
Prefix to mask in your head
Split the prefix into whole octets and leftover bits. A /27 is three whole octets, 24 bits, plus 3. Each whole octet is 255. The leftover bits give one of these values:
| Leftover bits | Mask octet | Block size |
|---|---|---|
| 1 | 128 | 128 |
| 2 | 192 | 64 |
| 3 | 224 | 32 |
| 4 | 240 | 16 |
| 5 | 248 | 8 |
| 6 | 252 | 4 |
| 7 | 254 | 2 |
So /27 is 255.255.255.224, and /11 is 255.224.0.0. Subnet masks and how to calculate them goes through the reasoning.
Powers of two
| Bits | Value |
|---|---|
| 1 to 4 | 2, 4, 8, 16 |
| 5 to 8 | 32, 64, 128, 256 |
| 9 to 12 | 512, 1,024, 2,048, 4,096 |
| 13 to 16 | 8,192, 16,384, 32,768, 65,536 |
Block boundaries in one octet
| Block size | Starting values |
|---|---|
| 128 | 0, 128 |
| 64 | 0, 64, 128, 192 |
| 32 | 0, 32, 64, 96, 128, 160, 192, 224 |
| 16 | 0, 16, 32, 48, 64, 80, and so on to 240 |
| 8 | 0, 8, 16, 24, 32, and so on to 248 |
| 4 | 0, 4, 8, 12, 16, and so on to 252 |
Which octet is partial depends on the prefix: /1 to /7 in the first, /9 to /15 in the second, /17 to /23 in the third and /25 to /31 in the fourth.
The method
Octets before the partial one are copied. Octets after it are 0 in the network address and 255 in the broadcast address.
Example 1: a small segment
Question: For 192.168.1.100/28, find the network, broadcast and host range.
- Partial octet: fourth. Mask 240, block size 16.
- 100 falls between 96 and 112.
- Network:
192.168.1.96 - Broadcast:
192.168.1.111 - Hosts:
192.168.1.97to192.168.1.110(14)
Example 2: a boundary in the third octet
Question: Which subnet holds 10.14.77.200/21?
- Partial octet: third. Mask 248, block size 8.
- 77 falls between 72 and 80.
- Network:
10.14.72.0 - Broadcast:
10.14.79.255 - Hosts:
10.14.72.1to10.14.79.254(2,046)
Note that 10.14.77.200 ends nowhere near an edge, and 10.14.75.255 would be a normal host here.
Example 3: choose a prefix from a host count
Question: A segment needs 45 devices plus a gateway, with room to grow by half. What prefix?
Devices today: 46. Half again: 69. Add the network and broadcast: 71. The next power of two is 128, so use a /25. A /26 would hold 62 and fit today but not the growth.
Example 4: split a block into equal subnets
Question: Divide 172.16.40.0/22 into eight equal subnets.
Eight subnets need three more bits: /25. Each holds 128 addresses.
| Subnet | Network |
|---|---|
| 1 | 172.16.40.0/25 |
| 2 | 172.16.40.128/25 |
| 3 | 172.16.41.0/25 |
| 4 | 172.16.41.128/25 |
| 5 | 172.16.42.0/25 |
| 6 | 172.16.42.128/25 |
| 7 | 172.16.43.0/25 |
| 8 | 172.16.43.128/25 |
Example 5: split into different sizes
Question: From 192.168.100.0/24, make segments for 60, 28 and 12 hosts.
Allocate largest first:
- 60 hosts need 62 addresses, so a
/26:192.168.100.0/26 - 28 hosts need 30, so a
/27:192.168.100.64/27 - 12 hosts need 14, so a
/28:192.168.100.96/28
Free: 192.168.100.112/28 and 192.168.100.128/25. The technique is variable length subnet masking.
Example 6: summarize
Question: Combine 10.8.4.0/24, 10.8.5.0/24, 10.8.6.0/24 and 10.8.7.0/24.
Four contiguous blocks, and 4 divides by 4, so the answer is 10.8.4.0/22. See route summarization for lists that do not line up so neatly.
Example 7: same subnet or not
Question: Can 192.168.20.200/26 reach 192.168.20.180/26 without a router?
Block size is 64. The first is in the block starting at 192, the second in the block starting at 128. Different subnets, so they need a router.
Example 8: a large block in the second octet
Question: Find the network and broadcast for 10.93.4.20/11.
- Partial octet: second. A
/11is 8 whole bits plus 3, so the mask octet is 224 and the block size is 32. - 93 falls between 64 and 96.
- Network:
10.64.0.0 - Broadcast:
10.95.255.255 - Total addresses: 2 to the power of 21, which is 2,097,152.
Example 9: how many subnets and hosts
Question: A /20 is divided into /26 subnets. How many are there, and how many hosts does each hold?
The difference in prefix lengths is 6, so there are 64 subnets. Each /26 leaves 6 host bits, giving 64 addresses and 62 usable hosts. In general, subnets equal 2 to the power of the bits you added, and addresses per subnet equal 2 to the power of the bits left.
Example 10: find the nth subnet
Question: Starting from 172.18.0.0/16 and using /27 subnets, what is the twentieth?
Count from zero, so the twentieth is number 19. Each subnet is 32 addresses, so it starts 19 times 32, or 608, addresses into the block. That is 2 times 256 plus 96, giving 172.18.2.96/27. Its broadcast is 172.18.2.127.
Which question are you asking?
Most confusion comes from using the right arithmetic on the wrong question. Decide what you are given and what you want before touching a number.
Frequent traps
- Subtracting two from a route. A firewall rule for a
/24matches all 256 addresses. - Applying the block size to the wrong octet. A
/20steps by 16 in the third octet, not the fourth. - Rounding down. Thirty-one hosts do not fit in a
/27, which holds 30. - Forgetting growth. A segment sized exactly to today's devices will need renumbering later.
- Overlap. A new
/25cannot sit on top of a/26already in use inside it. - Mixing mask forms. Some access lists want the wildcard, most settings screens want the mask, and many modern tools want the slash.
A planning pattern to copy
For a small site, this layout avoids most arithmetic. Take one /16 from private space and give each segment a /24 whose third octet matches its VLAN number. Put the gateway at .1, fixed devices below .50 and the DHCP pool above. Only step down to smaller blocks for links and infrastructure, where the saving matters. The reasoning behind each choice is in planning a small office subnet scheme.
Special ranges worth knowing
| Range | Meaning |
|---|---|
| 10.0.0.0/8 | Private (RFC 1918) |
| 172.16.0.0/12 | Private (RFC 1918) |
| 192.168.0.0/16 | Private (RFC 1918) |
| 127.0.0.0/8 | Loopback |
| 169.254.0.0/16 | Link-local, self-assigned |
| 100.64.0.0/10 | Shared space for carrier-grade NAT |
| 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | Documentation examples |
| 224.0.0.0/4 | Multicast |
The 172.16.0.0/12 entry trips people up: it runs from 172.16.0.0 to 172.31.255.255. An address such as 172.32.0.1 is outside it. More detail is in reserved and special IPv4 ranges.
IPv6 quick reference
| Prefix | What it usually is | /64 networks inside |
|---|---|---|
| /48 | A site | 65,536 |
| /56 | A common home or small site delegation | 256 |
| /60 | A small delegation | 16 |
| /64 | One LAN | 1 |
| /128 | One address | none |
Split on multiples of four bits so each boundary falls on a hex digit. There is no broadcast address and no subtraction of two. Details are in IPv6 subnetting.
Quick sanity checks
Run these before you type a result into a device:
- The network address divides evenly by the block size in the partial octet.
- The broadcast address is odd in the last octet, since it ends in a one bit for any prefix up to /30.
- The network address is even in the last octet for the same reason.
- The gateway lies inside the subnet and is neither edge.
- No new block overlaps an existing one.
Working in binary when you need to
The block size method covers nearly everything, but a binary check settles arguments. Take 192.168.1.100/28 from the first example. Only the last octet needs converting:
100 = 0110 0100
240 = 1111 0000 (mask)
AND = 0110 0000 = 96 network
OR with inverted mask:
0110 1111 = 111 broadcast The mask keeps the first four bits of the octet. Clearing the other four gives the start of the block, and setting them gives the end. Every table on this page is a precomputed form of those two operations.
The same technique tests whether two blocks overlap. Because CIDR blocks always start on multiples of their size, two blocks are either completely separate or one sits entirely inside the other. They never overlap halfway. Compare the shorter of the two prefixes: if both starting addresses give the same network under that prefix, the longer block is inside the shorter one. For 10.1.4.0/22 and 10.1.6.0/24, apply /22 to 10.1.6.0 and you get 10.1.4.0, so the /24 is contained. For 10.1.8.0/24 you get 10.1.8.0, so it is separate.
Reading addresses off a live device
When you apply these tables to a real network, start by reading what is configured instead of assuming. On Windows, ipconfig shows the address and the dotted mask. On Linux, ip addr shows the address with its slash. On macOS, ifconfig shows the mask in hexadecimal, so 0xffffffc0 reads as 255.255.255.192, a /26.
With the address and prefix in hand, work out the network, broadcast and gateway position, then compare with what the router says. A disagreement between the two is a finding worth fixing before you look at anything more complicated.
Practice set
-
192.168.200.222/27: network and broadcast? -
172.20.130.5/18: network and broadcast? - How many
/28subnets fit in a/24? - Smallest prefix for 500 hosts?
Answers: first, 192.168.200.192 and 192.168.200.223. Second, block size 64 in the third octet, so 172.20.128.0 and 172.20.191.255. Third, 16. Fourth, /23, with 510 usable.
To check your own problems, use the CIDR calculator, and the IP address converter if you want to look at an address in other number forms. Work the answer by hand first, then compare. After a few dozen rounds you will stop needing the tables for everyday prefixes.