Free tool · IPv4 & IPv6 · runs in your browser
Subnet calculator
Enter a CIDR block such as 192.168.1.0/24, an address with a subnet mask, or a range like 10.0.0.5 - 10.0.0.20. You get the network and broadcast address, the usable host range, masks and host counts, and you can split the block into smaller subnets.
Result · IPv4 · CIDR block
172.16.0.0/12
| CIDR notation | 172.16.0.0/12 |
|---|---|
| Network address | 172.16.0.0 |
| Broadcast address | 172.31.255.255 |
| First usable host | 172.16.0.1 |
| Last usable host | 172.31.255.254 |
| Address range | 172. |
| Usable hosts | 1,048,574 |
| Total addresses | 1,048,576 |
| Subnet mask | 255.240.0.0 |
| Wildcard mask | 0.15.255.255 |
| Prefix length | /12 |
| Mask in binary | 11111111. |
| Network in binary | 10101100. |
| Network in hex | 0xac100000 |
| Network as integer | 2886729728 |
| Address class (historic) | B |
| Address type | Private network (RFC 1918) |
| Reverse DNS zone | 16. |
- The first address names the network and the last is the broadcast address, so neither is assigned to a host.
The basics
How CIDR notation works
An IPv4 address is 32 bits, usually written as four numbers from 0 to 255. In CIDR notation such as 192.168.1.0/24, the number after the slash is the prefix length: how many of those bits are the same for every address in the network. The rest are free to number the hosts.
So a /24 leaves 8 host bits, which is 28 = 256 addresses, from 192.168.1.0 to 192.168.1.255. Each extra bit of prefix halves the block: a /25 has 128 addresses, a /26 has 64. The subnet mask says the same thing in dotted form: 24 one-bits make 255.255.255.0.
IPv6 works the same way with 128 bits. A typical site gets a /48 or /56 and gives each LAN a /64.
How to read the result
- Network address is the first address of the block. It names the subnet and is not given to a device.
- Broadcast address is the last address. A packet sent to it reaches every host on the subnet, so it is not given to a device either.
- First and last usable host are the addresses you can assign, for example to your router and your devices. Usable hosts is how many there are: the total minus two.
- Subnet mask and wildcard mask are the prefix in dotted form, for device settings and for firewall or router access lists.
- Two sizes break the minus-two rule: a /31 has two usable addresses for a point-to-point link (RFC 3021), and a /32 is a single address.
- Address type tells you whether the block is public or one of the special ranges, such as private (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), carrier-grade NAT or documentation.
To convert one address between IPv4 and IPv6 forms, use the IPv4 to IPv6 converter. To match addresses against CIDR blocks in your own code, see IP to integer and CIDR matching.
IPv4 CIDR cheat sheet
Every prefix from /8 to /32 with its masks and host counts.
| CIDR | Subnet mask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
FAQ
Subnetting questions
What is CIDR notation?
CIDR (Classless Inter-Domain Routing) writes a network as an address, a slash and a prefix length, such as 192.168.1.0/24. The prefix length is the number of leading bits that are fixed for the whole network; the remaining bits number the hosts inside it. A /24 fixes 24 of the 32 IPv4 bits, leaving 8 bits, or 256 addresses.
How many hosts are in a /24?
A /24 has 256 addresses. The first (the network address) and the last (the broadcast address) are not given to hosts, so 254 are usable. In general an IPv4 block of prefix n has 2^(32 - n) addresses and 2^(32 - n) - 2 usable hosts, except /31 and /32.
Why does a /31 have 2 usable hosts?
A /31 has only two addresses. RFC 3021 lets point-to-point links use both, because a link between exactly two routers needs neither a network nor a broadcast address. A /32 is a single address, used for loopbacks and host routes.
What is a wildcard mask?
A wildcard mask is the inverse of the subnet mask: 0 bits must match and 1 bits can be anything. For 255.255.255.0 the wildcard mask is 0.0.0.255. Cisco access lists and OSPF configuration use wildcard masks.
Why is /64 the usual IPv6 subnet size?
IPv6 splits an address into a 64-bit network part and a 64-bit interface identifier. Stateless address autoconfiguration (SLAAC) and several other features expect that split, so a LAN is almost always a /64. Sites typically get a /48 or /56 to divide into /64s.
How do I turn an IP range into CIDR blocks?
Enter the range with a dash, such as 10.0.0.5 - 10.0.0.20. The calculator returns the smallest list of CIDR blocks that covers exactly those addresses, which is what most firewalls and access lists need.