# CIDR notation and subnet masks

> How to read CIDR notation such as /24, convert it to a subnet mask, and work out how many addresses a block contains.

Source: https://networkutility.org/guides/cidr-notation-and-subnet-masks/  
Section: Guides  
Updated: 2026-11-29

In CIDR notation, the number after the slash is the count of bits in the network part of an IPv4 address. `192.168.1.0/24` means the first 24 bits identify the network and the remaining 8 bits identify hosts, which gives 256 addresses. A larger number after the slash means a smaller network.

## How it works

An IPv4 address is 32 bits, written as four numbers from 0 to 255. The prefix length splits those 32 bits in two:

- **Network bits** are the same for every address in the block.
- **Host bits** vary from one address to the next.

With a prefix length of *n*, there are 32 − *n* host bits, so the block contains 2 raised to the power (32 − *n*) addresses.

## Usable hosts

In an ordinary subnet, two addresses are reserved: the first is the network address and the last is the broadcast address. Usable hosts are therefore the total minus 2. The exceptions are /31, which is used for point-to-point links where both addresses are usable, and /32, which is a single address.

## Reference table

| CIDR | Subnet mask | Addresses | Usable hosts |
| --- | --- | --- | --- |
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /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 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 | 1 (single host) |

Each step down the table halves the block.

## A worked example

Take `10.20.30.77/26`.

1. A /26 leaves 6 host bits, so each block holds 64 addresses.
2. In the last octet, blocks of 64 start at 0, 64, 128 and 192.
3. 77 falls in the block that starts at 64.
4. Network address: `10.20.30.64`. Broadcast address: `10.20.30.127`.
5. Usable hosts: `10.20.30.65` through `10.20.30.126`, which is 62 addresses.

## Private address ranges

Three IPv4 ranges are set aside for private networks and are not routed on the public internet:

| Range | CIDR |
| --- | --- |
| 10.0.0.0 to 10.255.255.255 | 10.0.0.0/8 |
| 172.16.0.0 to 172.31.255.255 | 172.16.0.0/12 |
| 192.168.0.0 to 192.168.255.255 | 192.168.0.0/16 |

## Common mistakes

- **Reading the prefix backwards.** A /16 is much larger than a /24.
- **Forgetting the reserved addresses.** A /29 has 8 addresses and only 6 usable hosts.
- **Starting a block on the wrong boundary.** A block's network address must be a multiple of its size, so `10.0.0.100/26` names a host inside `10.0.0.64/26`, not a network.
- **Overlapping subnets.** `10.0.0.0/24` and `10.0.0.128/25` overlap, which causes routing problems.
- **Cloud providers reserve more.** Many cloud platforms hold back extra addresses in each subnet, so check their documentation for the real usable count.

## IPv6

IPv6 uses the same slash notation with 128-bit addresses. A /64 is the standard size for a single network segment.

## Related

Once addressing is sorted out, see the port references for [SSH](/ports/port-22/), [DNS](/ports/port-53/) and [HTTPS](/ports/port-443/).
