Subnet Calculator
Work out a subnet’s range, mask and hosts, plus why “addresses minus two” returns zero at a /31 and minus one at a /32.
Any address inside a block describes the same block, so you can paste a host address rather than hunting for the network one. Nothing is uploaded.
"Addresses minus two" stops working at the bottom
Every subnet gives up two addresses, one for the network and one for the broadcast — so a /24 has 256 addresses and 254 hosts. Run the same formula to the end of the range and it returns 0 usable hosts for a /31 and -1 for a /32.
| Prefix | Mask | Addresses | "Minus two" says | Actually |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 | 4,094 |
| /24 | 255.255.255.0 | 256 | 254 | 254 |
| /26 | 255.255.255.192 | 64 | 62 | 62 |
| /28 | 255.255.255.240 | 16 | 14 | 14 |
| /29 | 255.255.255.248 | 8 | 6 | 6 |
| /30 | 255.255.255.252 | 4 | 2 | 2 |
| /31 | 255.255.255.254 | 2 | 0 | 2 ← |
| /32 | 255.255.255.255 | 1 | -1 | 1 ← |
Both exceptions are prefixes in daily use. RFC 3021 makes a /31 a point-to-point link with both addresses usable, which is why it is standard on router-to-router links, and a /32 is a single host route. The formula does not merely disagree there — it returns a negative host count, which is the sort of answer that should stop a calculation rather than be printed.
Splitting a subnet costs two hosts every time
Cutting a /24 in half does not give its 254 hosts in two halves. Each piece reserves its own network and broadcast, so the total falls with every split — and by /30 the block holds 128 usable addresses out of 256.
| Split into | Pieces | Hosts each | Total usable | Lost |
|---|---|---|---|---|
| /24 | 1 | 254 | 254 | 0 |
| /25 | 2 | 126 | 252 | 2 |
| /26 | 4 | 62 | 248 | 6 |
| /27 | 8 | 30 | 240 | 14 |
| /28 | 16 | 14 | 224 | 30 |
| /29 | 32 | 6 | 192 | 62 |
| /30 | 64 | 2 | 128 | 126 |
The cost is exactly two per piece, so it doubles with every split. At /30 half the parent has become overhead — which is the argument for handing out a few large subnets rather than many small ones, when the addressing plan allows it.
Sizing a subnet to a host count
The only block sizes are powers of two, so a subnet almost never fits its requirement snugly. Asking for one host more than a block holds doubles the block — and the boundary sits at 62, not 64, because the two reserved addresses move it.
| Hosts needed | Prefix | Addresses | Usable | Spare |
|---|---|---|---|---|
| 1 | /32 | 1 | 1 | 0 |
| 2 | /31 | 2 | 2 | 0 |
| 3 | /29 | 8 | 6 | 3 |
| 5 | /29 | 8 | 6 | 1 |
| 20 | /27 | 32 | 30 | 10 |
| 50 | /26 | 64 | 62 | 12 |
| 60 | /26 | 64 | 62 | 2 |
| 100 | /25 | 128 | 126 | 26 |
| 200 | /24 | 256 | 254 | 54 |
| 300 | /23 | 512 | 510 | 210 |
| 1,000 | /22 | 1,024 | 1,022 | 22 |
A worked block
192.168.1.0/26 runs from 192.168.1.0 to 192.168.1.63 — 64 addresses, of which 192.168.1.1 through 192.168.1.62 are the 62 usable hosts. The mask is 255.255.255.192 and the wildcard is 0.0.0.63, which are bit-for-bit complements: every bit the mask sets, the wildcard clears.
How to use
- Enter any address in the block — not just the network one.
- Set the prefix length.
- Read the range, mask, wildcard and host count.
- Watch where the familiar host formula breaks.
Frequently asked questions
Why is it addresses minus two?
Because each subnet reserves its first address to name the network and its last as the broadcast address, leaving the rest for hosts. A /24 has 256 addresses and 254 usable ones. That is the rule everyone learns, and it has two exceptions at the end of the range.
How many hosts does a /31 have?
Two, both usable. The minus-two formula says zero, which is why it is worth knowing the exception: RFC 3021 defines a /31 as a point-to-point link where neither reserved address is needed, and it is standard on router-to-router links for exactly that reason.
And a /32?
One — a single host route. The naive formula returns minus one there, which is the sort of answer that should stop a calculation rather than be printed. Any calculator that hands you a negative host count has applied a rule past the point where it holds.
Why does splitting a subnet lose addresses?
Because every new piece reserves its own network and broadcast address. A /24 split into two /25s gives 2 × 126 = 252 usable rather than 254, and split all the way to /30s it gives 64 × 2 = 128 — half the block has become overhead. The cost is exactly two per piece, so it doubles with every split.
How do I pick a prefix for a number of hosts?
Take the smallest block that holds them, remembering that the only sizes are powers of two. The boundaries sit at 62, 126, 254 and so on rather than 64, 128 and 256, because the two reserved addresses move them — so 63 hosts needs a /25, not a /26.
Do I need to enter the network address?
No. Any address inside the block identifies the same block, because the prefix simply masks off the host bits. Paste a host address you happen to have and the calculator finds the network for you.
What is the wildcard mask?
The bitwise complement of the subnet mask — every bit the mask sets, the wildcard clears. It is what access control lists on some equipment expect instead of a mask, and it is shown here so you do not have to invert one by hand.
Does this send anything anywhere?
No. Everything is computed in your browser, and nothing is uploaded.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.