🔧 Subnet Calculator
Calculate subnet masks, network addresses, broadcast addresses, and usable host ranges for any IP address and subnet mask.
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.
| Prefix | Mask | Addresses | Usable |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /26 | 255.255.255.192 | 64 | 62 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 (RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 host route |
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.