How to Calculate a Subnet Mask
A repeatable five-step method to turn any CIDR prefix into its mask, network address, broadcast address and host range — worked end to end with 192.168.1.130/26.
Published
192.168.1.130/26 the mask is 255.255.255.192, the network is 192.168.1.128, the broadcast is 192.168.1.191, and there are 62 usable host addresses.
The five steps
- Write the prefix as a binary mask. A /26 sets the first 26 bits to 1 and the rest to 0:
11111111.11111111.11111111.11000000, which in dotted decimal is255.255.255.192. - Count the host bits. Host bits = 32 − prefix = 32 − 26 = 6 bits. These are the zero positions in the mask.
- Compute the block size. Block size = 2host bits = 26 = 64 addresses. Every /26 covers a contiguous run of 64 addresses.
- Find the network address. Bitwise-AND the IP with the mask (see the octet math below). 192.168.1.130 AND 255.255.255.192 =
192.168.1.128. - Broadcast and hosts. Broadcast = network + block size − 1 = 192.168.1.128 + 64 − 1 =
192.168.1.191. Everything strictly between is a usable host address.
The AND operation, octet by octet
Only the fourth octet differs between the IP and the mask here, so that is the only octet where the AND changes anything:
| Decimal | Binary | |
|---|---|---|
| IP (last octet) | 130 | 10000010 |
| Mask (last octet) | 192 | 11000000 |
| AND result | 128 | 10000000 |
Reading down each column: wherever the mask has a 1, the IP bit passes through; wherever it has a 0, the result is forced to 0. That is how the host portion is erased and the network boundary appears. The procedure is the one originally specified for subnetting in RFC 950, and it has not changed since.
Worked example: 192.168.1.130/26
Applying the five steps above:
- Subnet mask
- 255.255.255.192
- Wildcard mask
- 0.0.0.63
- Network address
- 192.168.1.128
- Broadcast address
- 192.168.1.191
- First usable host
- 192.168.1.129
- Last usable host
- 192.168.1.190
- Total addresses
- 64
- Usable hosts
- 62
Quick reference: common prefixes
| Prefix | Subnet mask | Total addresses | Usable hosts | Last host octet* |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 | .254 |
| /25 | 255.255.255.128 | 128 | 126 | .126 |
| /26 | 255.255.255.192 | 64 | 62 | .62 |
| /27 | 255.255.255.224 | 32 | 30 | .30 |
| /28 | 255.255.255.240 | 16 | 14 | .14 |
| /30 | 255.255.255.252 | 4 | 2 | .2 |
*Shown for a network whose fourth octet is 0 (e.g. 192.168.1.0/24). The full table for every prefix lives on the subnet cheat sheet.
Common mistakes
- Off-by-one on usable hosts. A /26 holds 64 addresses and 62 usable hosts. People subtract 2 twice (getting 60) or forget to subtract at all (counting the network and broadcast as hosts). Subtract exactly once:
total − 2. - Forgetting that network and broadcast are reserved. If a VLAN needs exactly 62 devices, a /26 leaves zero headroom. Size up a prefix, or use the VLSM calculator to right-size multiple subnets at once.
- Assuming a /31 has zero usable hosts. Under the traditional rule, 21 − 2 = 0. But RFC 3021 explicitly defines two-address /31 subnets for point-to-point links, where both addresses are assigned — one per router interface (see RFC 3021). The same reasoning applies to /32 host routes, which carry exactly one address.
- Picking an unaligned network address. Blocks start only at multiples of their own size. The network for 192.168.1.130/26 is not 192.168.1.130 itself; /26 blocks in the last octet begin at .0, .64, .128 and .192, so the answer is 192.168.1.128.
Frequently asked questions
Why does /24 map to 255.255.255.0?
A /24 sets the first 24 of the 32 mask bits to 1 and the remaining 8 to 0. Written out per octet that is 11111111.11111111.11111111.00000000, and each octet read as a decimal number gives 255.255.255.0.
What does the subnet mask 255.255.255.255 mean?
All 32 bits are set, so the block holds exactly one address — a host route. Routing tables and ACLs use it to match a single IP rather than a range. The opposite extreme is 0.0.0.0/0, which matches every destination.
How many usable hosts does a /26 have?
A /26 has 26 network bits and 6 host bits, so it spans 64 addresses; reserving the first (network) and last (broadcast) leaves 62 usable hosts. Each /26 begins at a multiple of 64 in the fourth octet: .0, .64, .128 or .192.
What is the difference between a subnet mask and a wildcard mask?
The wildcard mask is the bitwise inverse of the subnet mask: where the mask has 1s the wildcard has 0s. A /26 is 255.255.255.192 as a subnet mask and 0.0.0.63 as a wildcard. Wildcards are used in Cisco-style ACLs, where a 0 bit means 'must match' and a 1 bit means 'don't care'.
Is the subnet mask sent with every packet?
No. The mask is local configuration only — it never leaves the device. Each host uses it internally to decide whether a destination address is on-link (deliver directly) or off-link (hand the packet to the default gateway).
Check your work
Hand calculations are great practice — verify them before they reach production:
IPv4 Subnet Calculator
Full breakdown of any CIDR block: network, broadcast, host range, wildcard mask and binary view.
Subnet Cheat Sheet
Every prefix from /0 to /32 with mask, wildcard and host counts on one printable page.
Want the theory behind slash notation first? Start with CIDR notation explained, or see the deep dive on the /26 subnet mask.