🔧 Subnet Calculator

Calculate subnet masks, network addresses, broadcast addresses, and usable host ranges for any IP address and subnet mask.

💡 Tip: Enter an IP address and subnet mask (or CIDR notation) and click "Calculate Subnet" for detailed analysis.
Enter an IP address and subnet mask, then click "Calculate Subnet" to view results.

How the network and broadcast addresses are worked out

Nothing is looked up in a table. The tool works on your address and your mask a bit at a time. A legal mask is a run of 1 bits followed by 0 bits, so counting the 1 bits gives the prefix length:

prefix          = count of 1 bits across the four mask octets
network[i]      = ip[i] AND mask[i]
broadcast[i]    = network[i] OR (NOT mask[i])
total addresses = 2^(32 - prefix)
usable hosts    = 2^(32 - prefix) - 2

Try 192.168.1.100 with 255.255.255.192. The mask carries 8 + 8 + 8 + 2 = 26 one bits, so it is a /26. In the last octet 100 is 01100100 and 192 is 11000000; AND them and you get 01000000, which is 64, so the network is 192.168.1.64. For the broadcast, NOT 192 is 63, and 64 OR 63 is 127, giving 192.168.1.127. That block holds 2^6 = 64 addresses and 62 usable hosts, .65 through .126.

Total addresses are not usable hosts

Two addresses in an ordinary subnet are not host addresses: the all-zeros host part is the network ID and the all-ones host part is the directed broadcast.

PrefixMaskAddressesUsable
/24255.255.255.0256254
/26255.255.255.1926462
/28255.255.255.2401614
/30255.255.255.25242
/31255.255.255.25422 (RFC 3021)
/32255.255.255.25511 host route
This tool subtracts 2 unconditionally, so it reports 0 usable for a /31 and a /32. RFC 3021 lets both addresses of a /31 be used on a point-to-point link, and a /32 is a host route with no broadcast to reserve. Note too that the mask box wants dotted decimal: a bare /24 is rejected.

Frequently asked questions

How many usable hosts are in a /26?

62. A /26 leaves 6 host bits, so 2^6 = 64 addresses, minus the network address and the broadcast address.

What subnet mask is /29?

255.255.255.248. Twenty-nine 1 bits fill the first three octets and the top five of the fourth, and 11111000 is 248. That is 8 addresses and 6 usable hosts.

Why is a /30 used for router links?

It is the smallest classic subnet that still leaves usable addresses: 4 total, minus network and broadcast, is exactly the 2 the routers at each end need.