Subnet masks are explained as binary prefixes, where the number after the slash indicates how many of IPv4’s 32 bits define the network. The post shows how to calculate total addresses with 2^(32 – prefix) and relates common CIDR blocks to their subnet masks.
It also explains why subnet sizes come in powers of two, how /24 equals 255.255.255.0, and why a request for 100 addresses typically requires a /25. The post gives historical context for subnetting and CIDR.
IP subnet masks look much more complicated than they actually are.
You might see an IP range written like this:
192.168.1.0/24
And naturally wonder:
Why does /24 mean 256 IP addresses?
If I want 100 IP addresses, why can’t I just use /100?
That would certainly be easier.
The reason is that the number after the slash does not represent the number of IP addresses. It represents how many bits of the IP address identify the network.
Once you understand that one idea, subnetting becomes much easier.
First, an IPv4 Address Is Really Just 32 Tiny Switches
An IPv4 address such as:
192.168.1.25
looks like four normal numbers.
But computers actually see it as 32 binary bits.
Think of them as 32 little switches that can each be either:
0 or 1
The familiar IPv4 format divides those 32 bits into four groups of 8:
8 + 8 + 8 + 8 = 32 bits
That is why an IPv4 address has four sections:
192 . 168 . 1 . 25
Each section can contain a value from 0 through 255.
So What Does /24 Mean?
The /24 simply means:
The first 24 of the 32 bits identify the network.
That leaves:
32 - 24 = 8
bits available for addresses inside that network.
Each remaining bit has two possibilities, 0 or 1.
So the number of possible addresses is:
2⁸ = 256
That’s it.
A /24 contains 256 total IPv4 addresses.
The Easiest Formula
You only need to remember this:
Total addresses = 2^(32 – CIDR number)
For a /24:
32 - 24 = 8
Then:
2⁸ = 256 addresses
For a /25:
32 - 25 = 7
2⁷ = 128 addresses
For a /26:
32 - 26 = 6
2⁶ = 64 addresses
For a /27:
32 - 27 = 5
2⁵ = 32 addresses
The pattern becomes very easy to see.
Every time the slash number goes up by one, the number of addresses is cut in half.
| CIDR | Subnet Mask | Total Addresses | Traditional Usable Hosts* |
|---|---|---|---|
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 512 | 510 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
*Traditionally, one address identifies the network itself and one is reserved as the broadcast address, leaving two fewer addresses for normal devices. There are special exceptions, such as /31 networks used on point-to-point links.
An Even Easier Trick
Start with the one almost everyone remembers:
/24 = 256 addresses
Then just keep cutting the number in half:
/24 = 256
/25 = 128
/26 = 64
/27 = 32
/28 = 16
/29 = 8
/30 = 4
Going the other direction, double it:
/23 = 512
/22 = 1,024
/21 = 2,048
/20 = 4,096
For most everyday subnet calculations, you can do this in your head.
What If I Need 100 IP Addresses?
This is where the system starts making sense.
You cannot request exactly 100 addresses using a normal CIDR block because subnet sizes are based on powers of two.
The nearby choices are:
/26 = 64 addresses
or:
/25 = 128 addresses
64 isn’t enough.
So you would normally need a:
/25 = 128 total addresses
Traditionally, 126 of those can be assigned to hosts.
You are essentially choosing the smallest standard-sized box that is big enough to hold what you need.
Why Are the Numbers Always 4, 8, 16, 32, 64, 128, 256?
Because computers use binary.
Humans normally count with ten digits:
0 1 2 3 4 5 6 7 8 9
Computers fundamentally work with two states:
0 and 1
So computer-friendly quantities naturally grow as powers of two:
2
4
8
16
32
64
128
256
512
1024
and so on.
Subnet sizes follow exactly the same pattern.
Where Does 255.255.255.0 Come From?
This part looks mysterious until you know what the subnet mask is doing.
A subnet mask is another 32-bit number.
A /24 means the first 24 bits are turned on:
11111111.11111111.11111111.00000000
Each group of eight 1s equals 255 in decimal.
So:
11111111 = 255
and:
00000000 = 0
Therefore:
11111111.11111111.11111111.00000000
becomes:
255.255.255.0
That is why:
/24
and:
255.255.255.0
describe the same prefix length.
A /25 adds one more 1:
11111111.11111111.11111111.10000000
That becomes:
255.255.255.128
You normally don’t need to calculate this manually anymore, but understanding it explains where those seemingly random subnet-mask numbers came from.
Why Was This System Created?
Subnetting wasn’t invented just to torture future network administrators.
IPv4 was designed around 32-bit addresses. As networks grew, organizations needed a way to divide a larger network into smaller internal networks without obtaining a completely separate network number for every department, building, or location.
The Internet’s standardized subnetting procedure was documented in RFC 950 in August 1985. It described using a bit mask to separate the network and subnet portions of an IPv4 address.
The early Internet also divided networks into fixed address classes. That eventually became inefficient as the Internet expanded.
In 1993, Classless Inter-Domain Routing, or CIDR, was introduced in RFC 1519. CIDR allowed networks to be described using flexible prefix lengths instead of being restricted to the old fixed address classes. One of its major goals was conserving IPv4 address space and slowing the explosive growth of Internet routing tables.
The CIDR specification was later updated by RFC 4632, which continues to describe the system of allocating and aggregating IPv4 address ranges using prefix lengths.
So /24 isn’t an arbitrary programmer’s shortcut.
It literally means:
“The first 24 bits belong to the network.”
The Whole Thing in 30 Seconds
If you forget everything else, remember these three rules:
1. IPv4 has 32 bits.
2. /24 means 24 bits describe the network.
3. Whatever bits are left determine how many addresses you have.
The formula is:
2^(32 - prefix)
Example:
/27
32 - 27 = 5
2⁵ = 32
So:
/27 = 32 total addresses
Or just memorize one starting point:
/24 = 256
Then halve the number as the prefix increases:
/24 = 256/25 = 128/26 = 64/27 = 32/28 = 16/29 = 8/30 = 4
Once you understand that pattern, subnet masks stop looking like some secret networking language and start looking like what they really are: a simple way of dividing 32 bits.

