Skip to content

IP Subnet Calculator (IPv4 CIDR & Subnet Mask)

Subnet calculator for IPv4. Enter an IP with a CIDR prefix or subnet mask to get the network, broadcast, usable host range, and wildcard mask.

By Updated Runs in your browser

IP Subnet Calculator guide

Work out IPv4 subnet details for firewall rules, VPC planning, router configs, and CCNA practice. Type an address with a /prefix or a dotted subnet mask and every value updates as you type.

What a subnet actually is

An IPv4 address is 32 bits, usually written as four decimal octets like 192.168.1.10. A subnet splits those bits into two parts: the network portion, which every device on the subnet shares, and the host portion, which is unique to each device. The CIDR prefix, the number after the slash, says how many leading bits belong to the network. In 192.168.1.10/24, the first 24 bits are network and the last 8 are host.

The subnet mask is the same information in dotted form: 24 ones followed by 8 zeros is 11111111.11111111.11111111.00000000, or 255.255.255.0. The calculator accepts either form and shows the mask in binary so you can see the split.

The math, step by step

Block size = 2^(32 − prefix). Network address = the IP with all host bits set to 0, which is the IP ANDed with the mask. Broadcast address = the network address with all host bits set to 1. First usable host = network + 1. Last usable host = broadcast − 1. Usable hosts = block size − 2.

The fastest mental shortcut is the interesting octet: the one where the mask is neither 255 nor 0. Subtract that mask octet from 256 to get the block size in that octet, then find the multiple of the block size at or below your IP's value in that octet. That multiple is where your network starts.

Worked example: 10.0.5.20/22

A /22 has 32 − 22 = 10 host bits, so the block holds 2^10 = 1,024 addresses. The mask is 22 ones: 255.255.252.0. The interesting octet is the third, where the mask is 252, so the block size there is 256 − 252 = 4.

Multiples of 4 in the third octet are 0, 4, 8, and so on. Our IP has 5 in the third octet, and the multiple of 4 at or below 5 is 4. So the network is 10.0.4.0, and the next network starts at 10.0.8.0. That makes the broadcast 10.0.7.255, the usable range 10.0.4.1 to 10.0.7.254, and the usable host count 1,022.

Second example with a mask instead of a prefix: 172.16.4.1 255.255.240.0. The mask 240 in the third octet means block size 16 and 4 ones in that octet, so the prefix is 8 + 8 + 4 = /20. The multiple of 16 at or below 4 is 0, so the network is 172.16.0.0/20, broadcast 172.16.15.255, and there are 4,094 usable hosts.

Quick reference: common prefixes

/8 = 255.0.0.0, 16,777,214 hosts. /16 = 255.255.0.0, 65,534 hosts. /20 = 255.255.240.0, 4,094 hosts. /22 = 255.255.252.0, 1,022 hosts. /23 = 255.255.254.0, 510 hosts. /24 = 255.255.255.0, 254 hosts. /25 = 255.255.255.128, 126 hosts. /26 = 255.255.255.192, 62 hosts. /27 = 255.255.255.224, 30 hosts. /28 = 255.255.255.240, 14 hosts. /29 = 255.255.255.248, 6 hosts. /30 = 255.255.255.252, 2 hosts.

Cloud networks reserve more than two addresses. AWS keeps the first four and the last address in every VPC subnet, so a /24 there gives you 251 usable IPs, not 254. Azure also reserves five per subnet. Size cloud subnets with that in mind.

Special ranges the calculator flags

Private (RFC 1918): 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16, used for home and corporate LANs behind NAT. Carrier-grade NAT (RFC 6598): 100.64.0.0/10, used by ISPs and by some VPN overlays such as Tailscale. Loopback: 127.0.0.0/8. Link-local: 169.254.0.0/16, which a device assigns itself when DHCP fails, so seeing one is usually a sign of a DHCP problem. Multicast: 224.0.0.0/4.

A classic gotcha is 172.16.0.0/12. It covers 172.16.0.0 through 172.31.255.255, not the whole 172.x.x.x space. An address like 172.32.1.1 is public.

Mistakes that break networks

Assigning the network or broadcast address to a host. Using a mask that is not contiguous, such as 255.0.255.0, which is invalid and rejected here. Overlapping subnets between two sites you later connect over a VPN, which is why planning with distinct ranges from day one matters. And forgetting that /31 and /32 are special: a /31 point-to-point link has two usable addresses and no broadcast (RFC 3021), while a /32 is a single host route.

How we calculate: sources

Frequently asked questions

How many usable hosts are in a /24?

254. A /24 has 2^8 = 256 addresses; the first is the network address and the last is the broadcast address, leaving 254 for hosts. The general formula is 2^(32 − prefix) − 2.

What subnet mask is /24?

255.255.255.0. Each 255 is eight 1-bits, so /24 means 24 ones followed by 8 zeros. /16 is 255.255.0.0, /20 is 255.255.240.0, and /27 is 255.255.255.224.

How do I find the network address?

AND the IP address with the subnet mask bit by bit. For 192.168.1.10/24, the mask keeps the first three octets and zeroes the last, giving 192.168.1.0.

Why does a /31 show 2 usable hosts?

RFC 3021 allows /31 subnets on point-to-point links, where no network or broadcast address is needed, so both addresses are usable. A /32 identifies a single host.

What are the private IP ranges?

RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 for private networks. They are not routed on the public internet. The calculator labels these automatically.

What is a wildcard mask?

The inverse of the subnet mask, used in Cisco ACLs and OSPF. For 255.255.255.0 the wildcard is 0.0.0.255. Subtract each mask octet from 255 to get it.

Does it support IPv6?

Not yet. This calculator is IPv4 only. IPv6 subnets are usually /64 for a LAN, which holds 2^64 addresses, so host counting works very differently.

Is my data uploaded?

Everything runs in your browser. Nothing you enter is uploaded to a server or stored by us.

How do I choose a subnet size?

Count the hosts you need, add room to grow, and pick the smallest block that fits: hosts + 2 ≤ 2^(32 − prefix). For 50 devices, a /26 (62 usable) works; for 200, use a /24 (254 usable).

What does 0.0.0.0/0 mean?

Every IPv4 address. It is the default route in routing tables and the any source in firewall rules, so treat allow rules for 0.0.0.0/0 with care.