CIDR and Subnet Calculation: A Beginner-Friendly Guide
Anyone stepping into networking runs into two concepts sooner or later: CIDR and subnetting. Notations like /24 and /26 look intimidating at first, but they rest on a surprisingly simple logic. This guide starts from the structure of an IP address and walks all the way to calculating network and broadcast addresses by hand, with examples. It's also a handy refresher before an exam.
What Are an IP Address and a Subnet Mask?
An IPv4 address is made of 32 bits, split into four 8-bit groups (octets) for readability:
192 . 168 . 1 . 10
11000000.10101000.00000001.00001010
Each octet holds a value from 0 to 255. But an IP address alone isn't enough; we need to know which part identifies the network and which part identifies the device (host). That's the job of the subnet mask.
The subnet mask is also 32 bits. Starting from the left, the 1 bits mark the network portion and the 0 bits mark the host portion:
255.255.255.0
11111111.11111111.11111111.00000000
└──────── network (24 bits) ──┘└ host (8 bits) ┘
How Does CIDR Notation Work?
CIDR (Classless Inter-Domain Routing) expresses how many bits belong to the network with a single number, instead of spelling out a mask like 255.255.255.0. That number is called the prefix, written after a /.
/24→ first 24 bits network, remaining 8 bits host (255.255.255.0)/26→ first 26 bits network, remaining 6 bits host (255.255.255.192)/16→ first 16 bits network, remaining 16 bits host (255.255.0.0)
In other words, the larger the prefix, the bigger the network portion and the smaller the host portion (and thus the device count). A /26 is a smaller network than a /24.
Instead of doing these conversions by hand, you can enter a prefix into the CIDR Calculator and see its mask instantly.
Network Bits and Host Bits
At the heart of subnetting lies a single rule: 32 = network bits + host bits.
- Network bits (prefix): distinguish one network from another. This part is identical on every device in the same network.
- Host bits: give each device within the network its own address.
From the number of host bits, we calculate how many addresses fit in the network:
Total addresses = 2^(host bits)
Usable hosts = 2^(32 − prefix) − 2
Why −2? Because every network reserves two addresses:
- Network address (all host bits 0): represents the network itself.
- Broadcast address (all host bits 1): used to send a packet to all devices in the network at once.
Neither of these can be assigned to a device, so they're subtracted.
Step-by-Step Worked Example: 192.168.1.0/26
Let's combine all of this in a real example. We'll break down the 192.168.1.0/26 network.
1. Prefix and host bits:
Prefix = 26, so host bits = 32 − 26 = 6 bits.
2. Subnet mask:
26 ones, 6 zeros:
11111111.11111111.11111111.11000000
255 .255 .255 .192
3. Total and usable addresses:
- Total addresses = 2^6 = 64
- Usable hosts = 2^6 − 2 = 62
4. Block size (subnet step):
Since the host bits live in the last octet, blocks advance in steps of 256 − 192 = 64. So /26 networks fall into these ranges:
| Network address | First host | Last host | Broadcast |
|---|---|---|---|
| 192.168.1.0 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 |
| 192.168.1.64 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 |
| 192.168.1.128 | 192.168.1.129 | 192.168.1.190 | 192.168.1.191 |
| 192.168.1.192 | 192.168.1.193 | 192.168.1.254 | 192.168.1.255 |
Reading the first row: in 192.168.1.0/26, the network address is 192.168.1.0, the broadcast is 192.168.1.63, the usable range is .1 through .62, and a total of 62 devices can be addressed.
Rather than build this table by hand, you can feed an IP and prefix into the Subnet Calculator and get the network address, broadcast, and host range in seconds.
Wildcard Masks for ACLs
On Cisco routers, access lists (ACLs) and protocols like OSPF use a wildcard mask instead of a subnet mask. A wildcard mask is the bit-for-bit inverse of the subnet mask:
Subnet mask : 255.255.255.192
Wildcard mask : 0.0.0.63
A handy shortcut: for each octet, compute 255 − mask value. In a wildcard mask, a 0 bit means "must match" and a 1 bit means "don't care." For example, 192.168.1.0 0.0.0.63 covers every address in the /26 block in a single line. To verify the conversion, use the Wildcard Mask Calculator.
Why Do We Subnet?
Subnetting isn't just an academic topic; it delivers real benefits in production networks:
- Efficient address use: Handing a whole
/24(254 hosts) to a 10-device department is wasteful. A/28(14 hosts) is just right. - Performance: Smaller broadcast domains cut down unnecessary broadcast traffic.
- Security and isolation: Splitting departments into separate subnets lets you control traffic between them with firewalls and ACLs.
- Manageability: Troubleshooting and address planning become far more orderly.
Quick Reference
Here's a summary of commonly used prefixes:
| CIDR | Subnet mask | Usable hosts |
|---|---|---|
| /30 | 255.255.255.252 | 2 |
| /29 | 255.255.255.248 | 6 |
| /28 | 255.255.255.240 | 14 |
| /26 | 255.255.255.192 | 62 |
| /24 | 255.255.255.0 | 254 |
| /16 | 255.255.0.0 | 65,534 |
Summary
CIDR and subnetting follow a far more logical system than they first appear to. The key things to remember:
- An IP address is 32 bits; the subnet mask splits it into network and host portions.
- The CIDR prefix (
/24,/26) shows how many bits belong to the network. - Usable hosts = 2^(32 − prefix) − 2 (the network and broadcast addresses are subtracted).
- A wildcard mask is the inverse of the subnet mask and is used in ACLs.
If you're curious about the decimal-integer form of an IP, check out the IPv4 to Integer Converter, and to look up general IP details, try IP Lookup. You can reach all networking tools from the /en/tools/network/ page.
Note: Every tool on MagmaNex runs entirely in your browser. None of the IP or network data you enter is sent to a server; no sign-up is required, and it's free.

