Subnet Calculator (CIDR)
Enter an IPv4 address with a CIDR prefix, for example
192.168.1.0/24, to calculate its network address, broadcast
address, netmask, and usable host range. Any host address within the subnet
works as input. Everything runs in your browser.
What CIDR notation means
An IPv4 address is 32 bits, usually written as four decimal octets. A CIDR
prefix such as /24 states how many of those leading bits identify
the network. The remaining bits identify the
host within it.
For 192.168.1.0/24, the first 24 bits are the network, leaving
8 bits for hosts. In binary:
Address: 11000000.10101000.00000001.00000000
Mask: 11111111.11111111.11111111.00000000
|------ network ------| |-host-|
Everything follows from that split:
- The netmask is the prefix written as an address, here 255.255.255.0.
- The network address sets all host bits to 0.
- The broadcast address sets all host bits to 1.
- Everything between them is a usable host address.
With 8 host bits there are 2⁸ = 256 addresses, minus the network and broadcast addresses, giving 254 usable hosts.
Prefix reference table
| CIDR | Netmask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /22 | 255.255.252.0 | 1024 | 1022 |
| /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 | single host |
Each step in the prefix halves or doubles the network size. Going from /24 to /25 splits one network into two, /26 into four, and so on.
Examples
| CIDR | Network | Broadcast | Usable hosts |
|---|---|---|---|
192.168.1.0/24 | 192.168.1.0 | 192.168.1.255 | 254 |
10.0.5.130/26 | 10.0.5.128 | 10.0.5.191 | 62 |
172.16.0.0/20 | 172.16.0.0 | 172.16.15.255 | 4094 |
192.168.1.5/32 | 192.168.1.5 | 192.168.1.5 | single host |
The second row shows why entering any host address works: 10.0.5.130 with a /26 prefix belongs to the network starting at 10.0.5.128, so the calculator normalizes it down.
Private address ranges
Three IPv4 ranges are reserved for private networks and never routed on the public internet:
| Range | CIDR | Addresses | Typical use |
|---|---|---|---|
| 10.0.0.0 to 10.255.255.255 | 10.0.0.0/8 | 16.7 million | Large corporate networks |
| 172.16.0.0 to 172.31.255.255 | 172.16.0.0/12 | 1 million | Medium networks, Docker defaults |
| 192.168.0.0 to 192.168.255.255 | 192.168.0.0/16 | 65,536 | Home and small office routers |
Also worth recognizing: 127.0.0.0/8 is loopback,
169.254.0.0/16 is link-local (an address in this range usually
means DHCP failed), and 224.0.0.0/4 is multicast.
Practical subnetting
Splitting a network
To divide 192.168.1.0/24 into four equal subnets, add two bits to the prefix, giving /26. Each holds 64 addresses with 62 usable hosts:
- 192.168.1.0/26, hosts .1 to .62
- 192.168.1.64/26, hosts .65 to .126
- 192.168.1.128/26, hosts .129 to .190
- 192.168.1.192/26, hosts .193 to .254
The rule: adding n bits to the prefix creates 2n subnets.
Sizing a subnet
Work backwards from the host count, remembering to add two for the network and broadcast addresses. Needing 100 hosts means 102 addresses, so /25 with 126 usable hosts is the smallest fit. A /26 with 62 would be too small.
The /31 special case
Normally the network and broadcast addresses are unusable, which would leave a /31 with zero hosts. RFC 3021 makes an exception for point-to-point links, where both addresses are usable, since a link between exactly two routers needs no broadcast address. This saves addresses on links that would otherwise waste a /30.
Frequently asked questions
What if my address is not the network address?
Any host address within the subnet works. The calculator normalizes it down to the network address automatically.
Why are two addresses unusable in each subnet?
The first is the network identifier and the last is the broadcast address. Neither can be assigned to a host. The exceptions are /31 and /32.
What about /0 and /32?
Both are valid. /0 covers the entire address space and is used
for default routes. /32 identifies exactly one host, commonly
used in firewall rules and routing entries.
How do I calculate the number of hosts?
2(32 minus prefix) minus 2. For /26 that is 2⁶ minus 2 = 62.
What is the difference between a netmask and a CIDR prefix?
They express the same thing. /24 and
255.255.255.0 both mean the first 24 bits are the network
portion. CIDR notation is simply more compact.
Does this handle IPv6?
Not currently. This calculator covers IPv4 only. IPv6 uses 128-bit addresses and different conventions, most notably /64 as the standard subnet size.
Related tools
- Number base converter, for the binary arithmetic behind masks
- Data size converter, for bandwidth and storage units
- All developer tools