On this pageHow to read a prefix
CIDR notation is the /24 at the end of an address range, and it turns up everywhere a server admin works: firewall sources, VPN peer settings, routing tables, Docker networks and cloud firewall rules. It arrived in 1993 to replace the wasteful class A, B and C system, and the idea is simple: the number after the slash says how many leading bits identify the network. This page is the reference to keep open, followed by the mental shortcuts and commands that save you from counting bits by hand.
How to read a prefix
203.0.113.0/24 means the first 24 of the 32 bits are the network part, and the remaining 8 bits number the hosts inside it. The size of any IPv4 block is 2 raised to the number of host bits:
/24: 32 − 24 = 8 host bits, 2⁸ = 256 addresses./26: 6 host bits, 64 addresses./32: no host bits, exactly one address.
In a classic subnet, the first address names the network and the last is the broadcast address, so usable hosts are the total minus two. Point-to-point links are the exception: a /31 gives both of its addresses to the two ends of the link (RFC 3021), and a /32 describes one host.
A worked example, 198.51.100.77/26:
| Item | Value |
|---|---|
| Netmask | 255.255.255.192 |
| Block size | 64 addresses |
| Network address | 198.51.100.64 |
| First and last usable host | 198.51.100.65 to 198.51.100.126 |
| Broadcast address | 198.51.100.127 |
IPv4 prefix table
| Prefix | Netmask | Addresses | Usable hosts | Where you see it |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | 10.0.0.0/8, large private networks |
| /12 | 255.240.0.0 | 1,048,576 | 1,048,574 | 172.16.0.0/12 private range |
| /16 | 255.255.0.0 | 65,536 | 65,534 | 192.168.0.0/16, Docker's default bridge |
| /20 | 255.255.240.0 | 4,096 | 4,094 | Cloud VPC subnets |
| /22 | 255.255.252.0 | 1,024 | 1,022 | Campus or large office |
| /23 | 255.255.254.0 | 512 | 510 | Two /24s combined |
| /24 | 255.255.255.0 | 256 | 254 | The classic LAN |
| /25 | 255.255.255.128 | 128 | 126 | Half a /24 |
| /26 | 255.255.255.192 | 64 | 62 | Small server segment |
| /27 | 255.255.255.224 | 32 | 30 | Office VLAN |
| /28 | 255.255.255.240 | 16 | 14 | Small block of public IPs |
| /29 | 255.255.255.248 | 8 | 6 | Business internet line |
| /30 | 255.255.255.252 | 4 | 2 | Legacy point-to-point link |
| /31 | 255.255.255.254 | 2 | 2 | Point-to-point link (RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 | One host in a firewall rule or route |
Subnetting in your head
Two shortcuts cover most real work.
Block size. Subtract the interesting octet of the netmask from 256. A /26 mask ends in 192, so blocks are 256 − 192 = 64 addresses wide and start at .0, .64, .128 and .192. Splitting 203.0.113.0/24 into four /26 networks gives:
| Subnet | Hosts | Broadcast |
|---|---|---|
| 203.0.113.0/26 | .1 to .62 | .63 |
| 203.0.113.64/26 | .65 to .126 | .127 |
| 203.0.113.128/26 | .129 to .190 | .191 |
| 203.0.113.192/26 | .193 to .254 | .255 |
One bit halves or doubles. Each step from /24 to /25 halves the block; each step back doubles it. Two neighbors combine into one shorter prefix only when they are aligned: 10.20.0.0/24 and 10.20.1.0/24 form 10.20.0.0/23, but 10.20.1.0/24 and 10.20.2.0/24 do not, because a /23 must start on an even third octet.
Ranges worth recognizing
| Range | Purpose |
|---|---|
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 |
Private networks (RFC 1918), never routed on the internet |
100.64.0.0/10 |
Shared address space for carrier-grade NAT (RFC 6598); some mesh VPNs use it too |
127.0.0.0/8 |
Loopback |
169.254.0.0/16 |
Link-local; many clouds serve instance metadata at 169.254.169.254 |
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 |
Documentation and examples (RFC 5737) |
224.0.0.0/4 |
Multicast |
0.0.0.0/0 |
Every IPv4 address: the default route, or "any source" in a rule |
IPv6 in CIDR terms
IPv6 uses the same notation over 128 bits. Nobody counts hosts; you count subnets, and the standard subnet is a /64, which stateless address autoconfiguration requires.
| Prefix | Typical meaning |
|---|---|
| /128 | One address, the IPv6 equivalent of a /32 |
| /64 | One LAN or one server's subnet |
| /56 | A home or small-site delegation: 256 subnets of /64 |
| /48 | A site or organization: 65,536 subnets of /64 |
| /32 | A typical provider allocation |
Reserved ranges to know: ::1/128 loopback, fe80::/10 link-local, fc00::/7 unique local addresses (in practice fd00::/8), 2001:db8::/32 documentation, joined by 3fff::/20 for documentation in RFC 9637, and ::/0 for every IPv6 address.
One practical consequence for firewall rules: home connections usually rotate the low 64 bits of their IPv6 address for privacy. To allow-list a colleague's home connection, allow their /64 (or the /56 their provider delegates), not a single /128.
Check your math
ipcalc prints the network, broadcast and host range for a prefix. The Debian and RHEL packages are different programs with different output, but both answer the same questions:
ipcalc 198.51.100.77/26
Python's standard library is on almost every server and gives exact answers:
python3 -c "import ipaddress as i; n=i.ip_network('198.51.100.77/26', strict=False); print(n, n.netmask, n.num_addresses, n[1], n[-2])"
python3 -c "import ipaddress as i; print(*i.ip_network('203.0.113.0/24').subnets(new_prefix=26))"
python3 -c "import ipaddress as i; print(i.ip_address('203.0.113.130') in i.ip_network('203.0.113.128/26'))"
The first prints 198.51.100.64/26 255.255.255.192 64 198.51.100.65 198.51.100.126, the second lists the four subnets from the table above, and the third answers True.
Mistakes that cause real outages
- A host address with a network prefix.
198.51.100.77/24is not a network; it is a host inside198.51.100.0/24. Some tools reject it, others silently widen it to the whole/24, which can open a firewall rule to 255 more addresses than you meant. Python'sipaddressrefuses it unless you passstrict=False, as in the example above. /24where/32was meant. One wrong digit in a source rule turns "my office address" into "my office address and 253 neighbors".- Overlapping ranges. A VPN that uses
192.168.1.0/24collides with the many home routers that use the same range, and traffic for the tunnel never leaves the laptop. - IPv4 rules only. Every rule that restricts IPv4 sources needs an IPv6 twin, or the service stays open over IPv6.
Where CIDR shows up in daily work
- Firewall sources.
sudo ufw allow from 198.51.100.0/24 to any port 22 proto tcpadmits a whole office range. A CloudSat cloud firewall rule accepts the same notation, IPv4 or IPv6, in its sources field. - VPN peers. In WireGuard,
AllowedIPs = 10.8.0.2/32routes one peer's address, while0.0.0.0/0, ::/0sends all traffic through the tunnel. - Docker networks. The default bridge uses
172.17.0.0/16, and new networks take further blocks from172.16.0.0/12and192.168.0.0/16. If that collides with an office or VPN range, setdefault-address-poolsin/etc/docker/daemon.json. - Routing tables.
ip routeprintsdefault via ..., which is simply0.0.0.0/0.
FAQ
Why does a /24 have 254 usable hosts, not 256?
The first address identifies the network and the last is the broadcast address. Neither can be assigned to a host in a normal subnet.
Is CIDR notation the same as a subnet mask?
They carry the same information. /26 and 255.255.255.192 describe the same 26 network bits; CIDR is shorter and also works for IPv6, which has no dotted mask.
Can I use a /31 on a link between two routers?
Yes. RFC 3021 allows it, and current router and server operating systems support it. It saves two addresses per link compared with a /30.
What is the smallest range I should allow in a firewall?
As small as the traffic allows: a /32 or /128 for one fixed address, the provider's prefix for a dynamic one. Avoid 0.0.0.0/0 on management ports such as SSH and RDP.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




