CIDR notation and subnet masks from the ground up
In one line: What 192.0.2.0/24 actually means: network and broadcast addresses, usable host counts, subnet masks and wildcard masks in one place.
192.0.2.0/24 is two things: an address and a number after the slash. The number says how many leading bits identify the network — 24 here — so the remaining 8 bits belong to hosts and the block contains 2⁸ = 256 addresses.
What the prefix decides
IPv4 has 32 bits and IPv6 has 128. A prefix length p leaves 32 − p or 128 − p host bits, and the total number of addresses is two to that power. A longer prefix means a smaller block: /24 is one 256th of a /16.
| CIDR | Total | Usable | Subnet mask |
|---|---|---|---|
| /24 | 256 | 254 | 255.255.255.0 |
| /25 | 128 | 126 | 255.255.255.128 |
| /26 | 64 | 62 | 255.255.255.192 |
| /27 | 32 | 30 | 255.255.255.224 |
| /28 | 16 | 14 | 255.255.255.240 |
| /29 | 8 | 6 | 255.255.255.248 |
| /30 | 4 | 2 | 255.255.255.252 |
| /31 | 2 | 2 | 255.255.255.254 |
| /32 | 1 | 1 | 255.255.255.255 |
Usable is 2ⁿ−2 because the lowest address (the network) and the highest (the broadcast) cannot belong to a host. The exceptions are /31, where RFC 3021 lets point-to-point links use both addresses, and /32, a single address naming one host.
Mask and wildcard
A subnet mask sets network bits to 1 and host bits to 0. The wildcard mask is its complement and is what access control lists and OSPF configurations expect. Added together they always make 255.255.255.255.
/26 mask 255.255.255.192 11111111.11111111.11111111.11000000
wildcard 0.0.0.63 00000000.00000000.00000000.00111111
network 192.0.2.0 (all six host bits cleared)
broadcast 192.0.2.63 (all six host bits set)
usable 192.0.2.1 – 192.0.2.62 (62 addresses)
Common mistakes
- Treating a host address as the network.
10.0.0.37/24is normalised to10.0.0.0/24. Check the prefix when you write a firewall rule. - Reusing private space blindly. RFC 1918 gives
10.0.0.0/8,172.16.0.0/12and192.168.0.0/16, and every organisation can use them. Any future connection needs a range check first. - Putting real addresses in documents. Documentation should use RFC 5737 blocks —
192.0.2.0/24,198.51.100.0/24,203.0.113.0/24— which never collide with a real service. - Assuming only /30 is point-to-point. Modern equipment also accepts
/31on point-to-point links and saves two addresses.
Where the numbers come from
All of this is bit arithmetic. The network address is the address AND the mask; the broadcast is the address OR the inverted mask. IPv6 is 128 bits, which is hard to do by hand and wrong with JavaScript's 32-bit bitwise operators. CidrPlan stores every address as a BigInt, so a block such as 2001:db8::/32 is exact to the last bit.
Everything is calculated in your browser. The ranges you type are not stored on a server.
Back to the CIDR calculatorFrequently asked questions
Why can a /24 only use 254 addresses?
The lowest address is the network and the highest is the broadcast, so two of the 256 addresses are reserved.
How do a subnet mask and a wildcard mask differ?
The mask sets network bits to 1; the wildcard sets them to 0. They are bitwise inverses, and ACLs and OSPF use the wildcard form.
What happens if I type a host address with a prefix?
It is normalised to its network. 10.0.0.37/24 describes the same block as 10.0.0.0/24.
Sources
- RFC 1918 — Address Allocation for Private Internets
- RFC 5737 — IPv4 Address Blocks Reserved for Documentation
- RFC 3021 — Using 31-Bit Prefixes on IPv4 Point-to-Point Links
Read next
- Designing AWS VPC subnets around five reserved IPsVPC CIDR is /16 to /28, five addresses are reserved in every subnet, and a /28 leaves only 11. Sizing rules, an availability-zone layout and Terraform.
- VLSM: splitting a range by real host requirementsWhy equal-size FLSM wastes space, and how VLSM places the largest requirement first, aligns every block and reports the leftover space.
- IPv6 notation and exact 128-bit arithmeticEight groups, :: compression and RFC 5952, why /64 is the standard subnet, and the Subnet-Router anycast that replaces broadcast.