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:
where n = the number of host bits (the zeros in your mask)
We subtract 2 because every subnet has two reserved addresses:
- Network address: The first address (e.g.,
192.168.1.0) identifies the subnet itself - Broadcast address: The last address (e.g.,
192.168.1.255) sends a message to everyone on the subnet
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:
| CIDR | Host Bits | Total Addresses | Usable Hosts |
|---|---|---|---|
| /24 | 8 | 256 | 254 |
| /25 | 7 | 128 | 126 |
| /26 | 6 | 64 | 62 |
| /27 | 5 | 32 | 30 |
| /28 | 4 | 16 | 14 |
| /29 | 3 | 8 | 6 |
| /30 | 2 | 4 | 2 |
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:
- The "block size" is 256 minus the last non-255 octet in the mask
- 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:
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.