How to subnet step by step, with worked examples
There is one trick behind every subnetting question: the block size. Find it and the rest is counting.
The method
- Find the interesting byte. It is the byte in which the mask stops being 255. For /26 (255.255.255.192) it is the fourth byte.
- Block size = 256 minus the mask value in that byte. 256 - 192 = 64. Subnets start at multiples of 64: 0, 64, 128, 192.
- Find the block your address is in. 130 lies between 128 and 191, so the network address is 192.168.1.128.
- Broadcast = next block start minus 1. 192 - 1 = 191, so 192.168.1.191.
- Hosts are everything in between. 192.168.1.129 to 192.168.1.190: 62 hosts.
Worked example 1
Address 192.168.1.130/26. Block size 64. Network 192.168.1.128, broadcast 192.168.1.191, hosts 192.168.1.129 to 192.168.1.190. Type it in the calculator to check.
Worked example 2: a /20
Address 172.16.20.77/20. The mask is 255.255.240.0, so the interesting byte is the third: block size 256 - 240 = 16. Third-byte blocks start at 0, 16, 32, and so on. 20 lies in the block starting at 16, so the network is 172.16.16.0. The broadcast is the end of that block: third byte 16 + 16 - 1 = 31, fourth byte 255, so 172.16.31.255. Hosts: 172.16.16.1 to 172.16.31.254. There are 4,094 usable hosts (2^12 - 2).
Worked example 3: how many subnets for 50 devices
You need subnets that hold at least 50 hosts. Host bits h must satisfy 2^h - 2 >= 50. h = 6 gives 62, so use 32 - 6 = /26. A /24 gives 2^(26-24) = 4 such subnets.
Check yourself with the numbers
| Address | Prefix | Network | Broadcast | Usable hosts |
|---|---|---|---|---|
192.168.1.130/26 | /26 | 192.168.1.128 | 192.168.1.191 | 62 |
172.16.20.77/20 | /20 | 172.16.16.0 | 172.16.31.255 | 4,094 |
10.1.2.3/8 | /8 | 10.0.0.0 | 10.255.255.255 | 16,777,214 |
203.0.113.77/29 | /29 | 203.0.113.72 | 203.0.113.79 | 6 |
192.168.5.200/27 | /27 | 192.168.5.192 | 192.168.5.223 | 30 |
These rows were calculated with Python's ipaddress module when this page was built, and the calculator on this site gives the same results.
Shortcuts to memorise
- The block sizes for the last byte: /25 = 128, /26 = 64, /27 = 32, /28 = 16, /29 = 8, /30 = 4.
- Usable hosts = block size - 2.
- To go from a mask byte to a block size: 256 minus the byte.
Common mistakes
- Using the wrong byte. Always find where the mask stops being 255 first.
- Forgetting the minus 2. The first and last addresses are not hosts.
- Starting subnets at the wrong place. They must start at multiples of the block size.
Why 256 minus the mask byte?
A byte has 256 values. The mask byte shows how many are fixed; the rest are the block.
How do I do it for IPv6?
IPv6 subnetting works in the same way with 128 bits, but nobody counts hosts. A /64 is the usual subnet.
This is an independent guide. It is not connected with IANA, the IETF or any network equipment maker. Address and port data come from the IANA registries as fetched on 14 November 2026; RFC texts were read from rfc-editor.org. Check the originals for anything you rely on.