What /24 means
CIDR notation (Classless Inter-Domain Routing, RFC 4632) writes a network as an address followed by a slash and a number: 192.168.1.0/24. The number is the prefix length, how many of the 32 bits of an IPv4 address identify the network; the remaining bits identify hosts inside it. A /24 fixes the first 24 bits and leaves 8 bits, or 256 addresses, for that network. CIDR replaced the old A, B and C classes in 1993 so networks could have any size.
Prefix, mask and hosts
The subnet mask is the prefix written as an address: 24 ones followed by 8 zeros is 255.255.255.0.
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /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 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point links, RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 (a single host) |
The rule: a /n has 2^(32 − n) addresses, and two of them are reserved, the network address and the broadcast address, so usable hosts = 2^(32 − n) − 2. Cloud providers may reserve more: AWS keeps 5 addresses of every VPC subnet.
A worked example
Take 10.20.30.77/26. The mask has 26 ones, so the last octet keeps 2 network bits: blocks of 64 addresses (0, 64, 128, 192). 77 falls in the block that starts at 64.
| Value | |
|---|---|
| Mask | 255.255.255.192 |
| Network | 10.20.30.64 |
| First host | 10.20.30.65 |
| Last host | 10.20.30.126 |
| Broadcast | 10.20.30.127 |
| Usable hosts | 62 |
In binary, 77 is 01001101; keeping the first two bits (01) and zeroing the rest gives 01000000 = 64. The subnet calculator does this for any address, the range expander turns a start and end address into the smallest CIDR, and decimal to binary shows the bits of each octet.
Private ranges and IPv6
- RFC 1918 private ranges:
10.0.0.0/8,172.16.0.0/12and192.168.0.0/16. They are not routed on the internet. - Carrier-grade NAT uses
100.64.0.0/10(RFC 6598). - In IPv6 the same notation applies to 128 bits: a LAN is normally a
/64, a site often gets a/48, and/128is one address. You can create a private IPv6 prefix with the ULA generator.
FAQ
How many hosts are in a /24?
256 addresses, 254 usable hosts, because the network (.0) and broadcast (.255) addresses are reserved.
What is the difference between /24 and 255.255.255.0?
None: they are two ways of writing the same mask. CIDR is shorter and works for any prefix length.
Can two subnets overlap?
They must not inside one routed network. 10.0.0.0/16 contains 10.0.5.0/24; using both as separate subnets causes routing conflicts.
Why does a /31 have two usable addresses?
RFC 3021 allows /31 on point-to-point links, where no broadcast address is needed, so both addresses can be used.