How do I calculate a subnet?
Reviewed by Prabath Thalangama · Last updated
Enter an IPv4 address with a prefix, such as 192.168.10.0/24, and the calculator returns the network and broadcast addresses, subnet mask, wildcard mask, first and last usable hosts, total and usable address counts, the address class and whether the address is private or public. Everything is calculated in your browser.
The prefix length (the number after the slash) says how many leading bits identify the network. A /24 leaves 8 bits for hosts, which is 256 addresses; the first is the network address and the last is the broadcast address, leaving 254 usable hosts.
Use it when planning VPC, Kubernetes pod and service CIDRs, writing firewall rules and ACLs, or checking whether two ranges overlap. An address without a prefix is treated as a single host (/32).
How do I use the subnet calculator?
- Enter an address in CIDR notation, for example 10.0.0.0/20.
- Read the usable host range and counts.
- Use the netmask for interface configuration and the wildcard mask for Cisco ACLs or OSPF.
How to read the results
- Network address
- The first address of the range, which identifies the subnet itself.
- Broadcast address
- The last address, used to reach every host in the subnet.
- Netmask and prefix length
- The same boundary written two ways: 255.255.255.0 is /24.
- Wildcard mask
- The inverse of the netmask (0.0.0.255 for a /24), used in Cisco ACLs and OSPF.
- First and last usable host
- The addresses you can assign to devices.
- Total addresses and usable hosts
- 2 to the power of the host bits, minus the network and broadcast addresses. A /31 has two usable addresses for point-to-point links (RFC 3021) and a /32 is a single address.
- IP class and scope
- The historical class (A, B, C...) and whether the address is in a private RFC 1918 range or publicly routable.
Common subnetting mistakes
Using the network or broadcast address for a host
In 192.168.1.0/24, .0 and .255 are reserved. Assign .1 to .254.
Forgetting cloud reserved addresses
AWS reserves 5 addresses in every subnet (the first four and the last), Azure also reserves 5, and Google Cloud reserves 4. A /28 on AWS gives 11 usable addresses, not 14.
Overlapping ranges
Two networks you want to connect by VPN or peering must not overlap. Plan VPC, on-premises, pod and service CIDRs together before you build.
Examples and command-line equivalents
Common IPv4 prefixes
/30 255.255.255.252 4 addresses 2 usable
/29 255.255.255.248 8 addresses 6 usable
/28 255.255.255.240 16 addresses 14 usable
/27 255.255.255.224 32 addresses 30 usable
/26 255.255.255.192 64 addresses 62 usable
/25 255.255.255.128 128 addresses 126 usable
/24 255.255.255.0 256 addresses 254 usable
/20 255.255.240.0 4096 addresses 4094 usable
/16 255.255.0.0 65536 addresses 65534 usablePrivate address ranges (RFC 1918)
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16Calculate on the command line
ipcalc 192.168.10.0/24
# Python, no extra packages
python3 -c "import ipaddress as i; n=i.ip_network('192.168.10.0/24'); print(n.netmask, n.broadcast_address, n.num_addresses)"Frequently asked questions
How many usable hosts are in a /24?
254. A /24 has 256 addresses, and the network and broadcast addresses cannot be assigned to hosts.
What is the difference between a subnet mask and a wildcard mask?
A subnet mask marks network bits with 1s (255.255.255.0); a wildcard mask is its inverse (0.0.0.255) and marks the bits that may vary. Cisco ACLs and OSPF use wildcard masks.
Does it support IPv6?
Not yet; it calculates IPv4 subnets. IPv6 subnets are almost always /64 for a LAN, which makes host counting unnecessary in practice.
Further reading
- How NAT actually works
- AWS VPC: Subnets, Route Tables, and What 'Public' Actually Means
- IPv6 for People Who Know IPv4
- RFC 4632: Classless Inter-domain Routing (CIDR)
- RFC 1918: Address allocation for private internets
- RFC 3021: Using 31-bit prefixes on point-to-point links
- Run a full Super Scan to check DNS, email, website and TLS for a domain at once.