CIDR notation and subnet masks explained, with a table
CIDR notation writes a network as an address and a prefix length, such as 192.168.1.0/24, where the number after the slash is how many leading bits identify the network. A /24 has 256 addresses, of which 254 can be given to hosts, and its subnet mask is 255.255.255.0.
By the Toolwright team · Published · Updated
What the number after the slash means
An IPv4 address has 32 bits. The prefix length says how many of them, counted from the left, name the network. The rest name the host inside it. In 192.168.1.0/24 the first 24 bits (192.168.1) name the network and the last 8 bits can be any of 256 values.
The subnet mask is the same idea written as an address: 24 one-bits followed by 8 zero-bits is 255.255.255.0. The wildcard mask, used in some router configurations, is the mask turned inside out: 0.0.0.255.
Reference table for common prefixes
| Prefix | 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 |
| /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) |
| /32 | 255.255.255.255 | 1 | 1 (a single host) |
Usable hosts are two fewer than the addresses because the first address names the network and the last is the broadcast address. A /31 is the exception, defined for links between two routers (RFC 3021), and a /32 is one address.
Two worked examples
Which network is 192.168.10.77/26 in? A /26 has 64 addresses, so networks start at multiples of 64 in the last number: 0, 64, 128 and 192. The address 77 sits between 64 and 127, so the network is 192.168.10.64/26. Its broadcast address is 192.168.10.127, and the usable hosts run from 192.168.10.65 to 192.168.10.126.
How do you split 192.168.10.0/24 into four equal subnets? Four subnets need two more bits, so the prefix grows from /24 to /26, and each subnet holds 64 addresses.
- 192.168.10.0/26 covers .0 to .63
- 192.168.10.64/26 covers .64 to .127
- 192.168.10.128/26 covers .128 to .191
- 192.168.10.192/26 covers .192 to .255
IPv6 uses the same idea
An IPv6 address has 128 bits, and the prefix length counts leading bits in the same way. A /64 is the usual size for a single local network, and 2001:db8::/32 is a block set aside for documentation and examples (RFC 3849). IPv6 has no broadcast address and no dotted subnet mask, so only the prefix length is used.
Private ranges
- 10.0.0.0/8 (10.0.0.0 to 10.255.255.255)
- 172.16.0.0/12 (172.16.0.0 to 172.31.255.255)
- 192.168.0.0/16 (192.168.0.0 to 192.168.255.255)
These three blocks are reserved for private networks (RFC 1918) and are not routed on the public internet.
Let a calculator do the sums
For anything beyond a table, such as splitting a /24 into four /26 subnets, turning an address range into the fewest CIDR blocks or merging a list of networks, the IP & Subnet Calculator does the arithmetic for IPv4 and IPv6, in your browser, with nothing sent anywhere.
Work out a network's mask, range and host count. Open IP & Subnet Calculator.
Writing firewall rules as well? The list of common port numbers is one search away.
Look up which service uses which port. Open Common Port Numbers.
Frequently asked questions
How many hosts are in a /24?
A /24 has 256 addresses and 254 usable host addresses, because the first is the network address and the last is the broadcast address.
What is the difference between a subnet mask and a prefix length?
They say the same thing. 255.255.255.0 and /24 both mean that the first 24 bits identify the network.
Does IPv6 use subnet masks?
IPv6 uses the same prefix-length notation, such as 2001:db8::/32, and has no broadcast address or dotted mask.