How to Calculate a Subnet

Run a Speed Test

Given an IP address and a mask, four numbers tell you everything about its subnet: where the network starts, where it ends, which addresses you can actually assign, and how many there are. Subnet calculators will spit these out instantly — but knowing how to work them by hand, with nothing but the "block size" trick, means you can reason about any network on the spot. This is the practical, worked method, no binary conversion required.

The Four Things You're Solving For

For any address-and-mask pair, subnetting boils down to finding four values. We will compute each in turn:

  • Network address — the first address, which names the subnet itself.
  • Broadcast address — the last address, used to reach every host at once.
  • Usable host range — every address between those two, which you can assign to devices.
  • Host count — how many usable addresses that range contains.

This page assumes you already know what a subnet and a CIDR mask like /26 are; here we focus purely on the arithmetic. The key idea throughout is that the mask splits the address into network bits (fixed across the subnet) and host bits (free to vary), and the four values fall out of that split.

Step 1: Find the Block Size

The single most useful number in fast subnetting is the block size — how far apart consecutive subnets sit. You get it from the subnet mask with one subtraction. First, identify the "interesting octet," the one where the mask is neither 255 (all network) nor 0 (all host). The block size is 256 − (that octet's value).

A short reference for the common masks within a single octet:

CIDRMask octetBlock sizeHost bits
/240 (next octet)2568
/251281287
/26192646
/27224325
/28240164
/2924883
/3025242

So for a /26, the mask is 255.255.255.192, the interesting octet is 192, and the block size is 256 − 192 = 64. Subnets of this size begin at multiples of 64 in that octet: 0, 64, 128, 192.

Step 2: Find the Network and Broadcast Addresses

Let's work a full example: 192.168.1.130 /26.

  1. Block size for /26 is 64 (from Step 1).
  2. Network address: round the interesting octet (130) down to the nearest multiple of 64. The multiples are 0, 64, 128, 192 — and 130 falls into the 128 block. So the network address is 192.168.1.128.
  3. Broadcast address: take the network address and add block size − 1. That's 128 + 63 = 191, giving 192.168.1.191.

The logic is simple once you see it: subnets march up in steps of the block size, so your address lives in the block that starts at the multiple just below it, and that block ends one address short of the next multiple. The next subnet would start at 192.168.1.192 — exactly one past this broadcast.

Step 3: Find the Usable Host Range and Count

The network and broadcast addresses are reserved and cannot be assigned to devices, so the usable hosts are everything strictly between them:

Network:    192.168.1.128   (reserved)
First host: 192.168.1.129
...
Last host:  192.168.1.190
Broadcast:  192.168.1.191   (reserved)

The first usable host is network + 1; the last usable host is broadcast − 1. For the count, use the host bits: a subnet has 2^(host bits) total addresses and 2^(host bits) − 2 usable ones. A /26 has 6 host bits, so 2^6 = 64 total and 64 − 2 = 62 usable. The "minus two" is always the network and broadcast addresses being set aside.

ValueResult for 192.168.1.130 /26
Network address192.168.1.128
First usable host192.168.1.129
Last usable host192.168.1.190
Broadcast address192.168.1.191
Usable hosts62

A Second Example, and the Edge Cases

Try 10.20.30.45 /28. The /28 block size is 256 − 240 = 16, with 4 host bits. Round 45 down to the nearest multiple of 16 → 32, so the network is 10.20.30.32. Broadcast is 32 + 15 = 4710.20.30.47. Usable range is .33 to .46, and the count is 2^4 − 2 = 14. The whole calculation takes seconds once the block-size habit is ingrained.

Two edge cases are worth knowing. A /31 has only 2 host bits' worth of address — actually just 2 addresses — and a special rule lets both be used as hosts (no network/broadcast reserved) for point-to-point links. A /32 is a single address, a host route to one machine. And remember the masks can fall in any octet: a /18 has its interesting octet in the third position (block size 64 there), so subnets step 10.0.0.0, 10.0.64.0, 10.0.128.0, and so on. The method never changes — find the block size, round down for the network, add block-size-minus-one for the broadcast. For the bigger picture of why networks are divided this way, see subnetting basics and VLSM.

Frequently Asked Questions

How do you calculate the network address of a subnet?

Keep the network bits and set the host bits to zero. In practice, find the block size for the mask and round the interesting octet down to the nearest multiple of it. With a /26 (block size 64), 192.168.1.130 rounds down to the network 192.168.1.128.

How do you find the broadcast address of a subnet?

It is the last address — the network address plus block size minus one. For a /26 network at 192.168.1.128 with block size 64, the broadcast is 128 + 63 = 192.168.1.191.

How many usable hosts are in a subnet?

Two to the power of the host bits, minus two — subtracting the network and broadcast addresses. A /24 (8 host bits) has 256 total and 254 usable; a /26 (6 host bits) has 64 total and 62 usable.

What is the block size in subnetting?

How far apart consecutive subnets sit in the interesting octet. It equals 256 minus that octet's value in the mask. For /26 the octet is 192, so the block size is 64, and subnets begin at 0, 64, 128, 192.

Why subtract 2 for usable hosts?

Each subnet reserves two addresses that cannot be assigned: the first identifies the network, and the last is the broadcast address. The usable range sits between them, so the count is two to the power of the host bits, minus two.

Related Guides

More From This Section