How to Calculate Subnets: Step-by-Step

Subnet calculation can seem like magic when you first start. But it's really just basic math — and once you see the pattern, you'll be calculating subnets in your sleep. Let's walk through it together.

Step 1: Understand the Building Block

At its core, subnetting divides a network into smaller pieces. The key formula you need to remember:

Total hosts per subnet = 2ⁿ - 2
where n = the number of host bits (the zeros in your mask)

We subtract 2 because every subnet has two reserved addresses:

Step 2: Convert the CIDR to Host Bits

Here's a quick reference table showing how many host bits you get with each CIDR prefix:

CIDRHost BitsTotal AddressesUsable Hosts
/248256254
/257128126
/2666462
/2753230
/2841614
/29386
/30242

Step 3: Calculate a Complete Subnet

Let's work through a real example. You have the IP address 192.168.1.100/26 and want to know everything about this subnet.

Step 3a: Find the Subnet Mask

CIDR /26 = 255.255.255.192
Binary: 11111111.11111111.11111111.11000000

The last octet has 2 ones (the network "borrows" 2 bits from the host portion).

Step 3b: Calculate the Network Address

IP:      192.168.1.100
Mask:    255.255.255.192

AND them together:
192.168.1.100 AND 255.255.255.192 = 192.168.1.64

Network Address: 192.168.1.64

Step 3c: Calculate the Broadcast Address

The broadcast is the network address with all host bits set to 1:

Network:  192.168.1.01000000
Host bits:              ^^ (last 6 bits)
Set to 1: 192.168.1.01111111 = 192.168.1.127

Broadcast Address: 192.168.1.127

Step 3d: Find Usable Host Range

First usable: 192.168.1.65  (network + 1)
Last usable: 192.168.1.126 (broadcast - 1)

Range: 192.168.1.65 - 192.168.1.126
Total usable hosts: 62

Step 4: Practice with More Examples

Example 1: /25 Subnet

IP: 10.0.0.50/25
- Network: 10.0.0.0
- Broadcast: 10.0.0.127
- Range: 10.0.0.1 - 10.0.0.126
- Usable hosts: 126

Example 2: /28 Subnet

IP: 172.16.10.75/28
- Network: 172.16.10.64
- Broadcast: 172.16.10.79
- Range: 172.16.10.65 - 172.16.10.78
- Usable hosts: 14

Example 3: /30 Subnet

IP: 192.168.1.10/30
- Network: 192.168.1.8
- Broadcast: 192.168.1.11
- Range: 192.168.1.9 - 192.168.1.10
- Usable hosts: 2

/30 subnets are perfect for point-to-point connections between routers — you only need 2 IP addresses!

The Quick Calculation Method

If you don't want to do binary math every time, here's a handy trick:

  1. The "block size" is 256 minus the last non-255 octet in the mask
  2. For /26 (mask 255.255.255.192): block size = 256 - 192 = 64

So the subnets fall at multiples of 64: 0, 64, 128, 192...

192.168.1.0/26   → 0-63
192.168.1.64/26  → 64-127
192.168.1.128/26 → 128-191
192.168.1.192/26 → 192-255

Use a Calculator to Save Time

While understanding the math is important, using a subnet calculator is much faster for real-world work. Our calculator handles all of this instantly:

👉 Try Our Subnet Calculator

Enter any IP address and subnet mask, and you'll get the network address, broadcast address, first/last usable IP, and total host count — all in a split second.


← Back to Blog | Privacy Policy | Contact Us