What is IPv4 Subnet & CIDR Calculator?
This IPv4 subnet calculator works out everything about a network from an IP address and a CIDR prefix. Enter 192.168.1.10 with /24 and it shows the network address (192.168.1.0), broadcast address (192.168.1.255), subnet mask (255.255.255.0), wildcard mask (0.0.0.255), the first and last usable host, how many usable hosts the subnet holds, the address class, whether the address is private or public, and the IP in binary.
It saves the binary arithmetic when you plan VPC and VLAN ranges, write firewall rules and access control lists, or check whether two addresses are on the same subnet.
How to use IPv4 Subnet & CIDR Calculator
- Enter an IPv4 address, such as 10.0.4.
- Choose the CIDR prefix length from /0 to /32 (for example /24 for 255.255.255.0).
- Read the network address, broadcast address, subnet mask and wildcard mask.
- Check the usable host range and host count to confirm the subnet is big enough.
- Copy the values into your router, cloud or firewall configuration.
Key features
- Network address, broadcast address, subnet mask and wildcard mask
- First and last usable host with usable and total host counts
- Every prefix from /0 to /32, including /31 point-to-point links
- CIDR cheat sheet with the mask and host count of every prefix from /8 to /32
- IP address class and private (RFC 1918) or public detection
- IP address shown in dotted binary notation
- Instant results with no page reloads
Common use cases
- Planning VPC and subnet ranges in AWS, Azure or Google Cloud
- Writing firewall rules, security groups and router ACLs (wildcard masks for Cisco)
- Checking whether two IP addresses belong to the same subnet
- Sizing VLANs and DHCP scopes for a given number of devices
- Studying for CCNA and other networking exams
Technical details & standards
The prefix length is the number of leading 1 bits in the 32-bit subnet mask: /24 is 255.255.255.0 and /20 is 255.255.240.0. The network address is the IP AND the mask, the broadcast address is the network address OR the wildcard mask (the inverted subnet mask), and a subnet holds 2^(32 − prefix) addresses. Two of them, the network and broadcast addresses, are not assignable to hosts, so usable hosts = 2^(32 − prefix) − 2.
Two prefixes are special: /31 has 2 usable addresses for point-to-point links (RFC 3021), and /32 describes a single host. Private ranges are flagged according to RFC 1918: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
How to calculate a subnet and IP range by hand
Every result the subnet mask calculator shows comes from the prefix length. Here is 10.0.4.17/22, a size that does not end on a neat octet boundary:
- Turn /22 into a mask: 22 one-bits followed by 10 zero-bits, which is 255.255.252.0.
- Find the block size in the octet where the mask stops being 255: 256 − 252 = 4, so networks start at 0, 4, 8, 12 … in the third octet.
- The address's third octet is 4, so the network address is 10.0.4.0 and the next network starts at 10.0.8.0.
- The broadcast address is one below the next network: 10.0.7.255.
- Usable hosts lie between them: 10.0.4.1 to 10.0.7.254, which is 2¹⁰ − 2 = 1,022 hosts.
Result: 10.0.4.17/22 is in network 10.0.4.0/22 (mask 255.255.252.0), with the usable IP range 10.0.4.1 – 10.0.7.254 and broadcast 10.0.7.255.
Subnet calculations in Python
Python's standard ipaddress module gives the same network, mask, broadcast and host range, which is handy in scripts that plan or audit IPv4 networks.
Python
import ipaddress
net = ipaddress.ip_network("10.0.4.17/22", strict=False)
net # IPv4Network('10.0.4.0/22')
net.netmask # IPv4Address('255.255.252.0')
net.broadcast_address # IPv4Address('10.0.7.255')
net.num_addresses - 2 # 1022 usable hosts
# CIDR prefix from a subnet mask
ipaddress.ip_network("0.0.0.0/255.255.255.248").prefixlen # 29strict=False lets you pass a host address; without it, ip_network expects the network address itself.
CIDR and subnet mask cheat sheet
Every IPv4 prefix from /8 to /32 with its subnet mask, wildcard mask and size. Usable hosts excludes the network and broadcast addresses, except for /31 point-to-point links (RFC 3021) and /32 single hosts.
| CIDR | Subnet mask | Wildcard mask | 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 |
Frequently asked questions
How many usable hosts are in a /24 subnet?
254. A /24 has 2^8 = 256 addresses; the first (network address) and last (broadcast address) cannot be assigned, leaving 254 usable hosts. A /25 has 126, a /26 has 62, a /27 has 30, a /28 has 14 and a /30 has 2.
How do I convert a CIDR prefix to a subnet mask?
Write the prefix length as that many 1 bits followed by 0 bits, then convert each 8-bit group to decimal. /26 is 11111111.11111111.11111111.11000000, which is 255.255.255.192.
What is a wildcard mask?
The inverse of the subnet mask: subtract each octet from 255. The wildcard mask for 255.255.255.0 is 0.0.0.255. Cisco access lists and OSPF configurations use wildcard masks instead of subnet masks.
Which IP address ranges are private?
RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16 for private networks. These addresses are not routed on the public internet and are typically used behind NAT.
What is the subnet mask for /29?
A /29 subnet uses 255.255.255.248. It has 8 addresses and 6 usable hosts.
How do I calculate CIDR from a subnet mask?
Count the 1 bits in the mask. For example, 255.255.255.0 has 24 of them, so it is /24.
What is the usable IP range of 192.168.1.0/24?
It is 192.168.1.1 to 192.168.1.254. .0 is the network address and .255 is the broadcast address.
How many usable IPs does an AWS /24 subnet have?
251. AWS reserves 5 addresses in every subnet: the first four and the last one.
Is my data safe?
Processing happens locally in your browser. Tool input is not sent to CodeUnpack servers.
Does it work offline?
Once the page has loaded, this tool can process input without an internet connection.