If someone gives you 192.0.2.77/27, you should be able to work out the subnet boundary, network address, conventional usable host range and directed broadcast without guessing. That calculation is more valuable than memorizing a chart, because a small addressing error can make a host believe a remote device is on its own link—or send packets to the wrong gateway.
Use one repeatable IPv4 method: locate the block boundary, identify the network and directed broadcast, and calculate the conventional host range. Apply the same method to variable-length subnet allocation and to diagnosing hosts with inconsistent masks. The worked addresses belong to documentation-only ranges and are not actual public hosts.
Understand what the slash number controls
An IPv4 address contains 32 bits. Prefix length — /27 in this example — reserves 27 of the 32 IPv4 bits for the network prefix. The remaining 32 − 27 = 5 bits identify addresses within that network. Those five bits yield 2^5 = 32 total addresses. In an ordinary broadcast-capable IPv4 subnet, one address identifies the network and one identifies the directed broadcast, leaving 30 traditional usable host addresses.
The prefix also tells you the subnet mask. A /27 has 27 one-bits followed by five zero-bits, which in decimal is 255.255.255.224. The last octet of the mask, 224, is 11100000 in binary. Its host-side size is 256 − 224 = 32, so subnet boundaries appear at multiples of 32 in the last octet: 0, 32, 64, 96, 128, 160, 192 and 224.
These are two descriptions of the same thing. Binary explains why the boundary falls where it does; the block-size shortcut lets you calculate it quickly in everyday work. Avoid treating the mask as merely a formatting decoration: it determines which destinations a host believes are on-link.
Work a complete /27 example
Take 192.0.2.77/27. The address ends in 77, and /27 means a block size of 32 in the last octet. The highest multiple of 32 not greater than 77 is 64. Therefore the subnet starts at 192.0.2.64 and occupies 32 addresses, through 192.0.2.95.
| What you need | Result | Reason |
|---|---|---|
| Address and prefix | 192.0.2.77/27 |
Input |
| Subnet mask | 255.255.255.224 |
27 network bits |
| Block size | 32 addresses | Five host bits |
| Network address | 192.0.2.64 |
Boundary at 64 |
| Directed broadcast | 192.0.2.95 |
Last address before next boundary, 96 |
| Traditional host range | 192.0.2.65–192.0.2.94 |
Between network and broadcast |
| Traditional usable host count | 30 | 32 minus two reserved endpoints |
Check the result two ways. First, 77 lies between 64 and 95. Second, the next /27 begins at 96; there should be no overlap. If your calculated network is 192.0.2.77, you have mistaken the assigned host address for the subnet boundary. If your broadcast is 96, you have accidentally used the first address of the next subnet.
The example also shows why the gateway address must be documented rather than guessed. It could be .65, .94 or another usable address chosen by the network design. There is no rule that the first host address must always be the gateway.
Translate between masks and block sizes
You do not need to memorize every IPv4 subnet mask. Find the interesting octet—the first octet of the mask that is neither 255 nor 0—and subtract its value from 256. This gives the block size in that octet. For /27, the interesting octet is the fourth, with mask value 224 and block size 32. For /20, the mask is 255.255.240.0, so the interesting octet is the third, with a block size of 16 there.
| CIDR | Mask | Total addresses | Traditional usable hosts |
|---|---|---|---|
/24 |
255.255.255.0 |
256 | 254 |
/25 |
255.255.255.128 |
128 | 126 |
/26 |
255.255.255.192 |
64 | 62 |
/27 |
255.255.255.224 |
32 | 30 |
/28 |
255.255.255.240 |
16 | 14 |
/29 |
255.255.255.248 |
8 | 6 |
/30 |
255.255.255.252 |
4 | 2 |
The fourth-octet table is convenient, but the method works for larger blocks too. For a /20 address such as 172.16.37.42/20, the third-octet block containing 37 begins at 32 and extends through 47. The network is 172.16.32.0/20; the directed broadcast is 172.16.47.255. The fourth octet spans all 256 values because it lies entirely in the host portion.
Do not subtract two from every possible prefix without considering context. A /31 can serve a point-to-point link under RFC 3021, where both assigned endpoints can be usable. A /32 refers to one address, often for a host route or loopback. The familiar minus-two shortcut describes ordinary subnets that reserve network and directed-broadcast endpoints; it is not a universal IPv4 law.
Solve a /26 example without binary arithmetic every time
Consider 198.51.100.142/26. A /26 leaves six host bits: 2^6 = 64 addresses. The fourth-octet mask is 192, and the block size is 256 − 192 = 64. Boundaries fall at 0, 64, 128 and 192. Because 142 falls between 128 and 191, the network is 198.51.100.128/26 and the broadcast is 198.51.100.191.
The conventional host range is 198.51.100.129–198.51.100.190, or 62 possible host addresses. To check the arithmetic, the next subnet starts at .192; .191 + 1 gives that boundary. If your host is configured as .142/25 instead, it considers .128–.255 local, which may differ from the router’s actual /26 policy. A host with the wrong mask can appear to reach nearby addresses while failing for a subset of remote destinations.
This mismatch is why a failed ping should not immediately lead to a changed access list. Verify the source address, prefix and default gateway first. Two hosts can each have plausible-looking addresses and still disagree about whether a destination is local.
Calculate /30 and point-to-point exceptions
For 192.0.2.150/30, the mask is 255.255.255.252, giving blocks of four addresses. The block that contains 150 begins at 148. Therefore the network is 192.0.2.148, directed broadcast 192.0.2.151, and the conventional usable endpoints are .149 and .150. This is why /30 is a familiar choice for numbered point-to-point links where traditional network/broadcast behavior is expected.
For a /31 point-to-point prefix such as 198.51.100.20/31, the two addresses .20 and .21 may both serve as link endpoints on systems supporting the relevant point-to-point convention. Do not label one a useless network address and the other a broadcast using the same rule as /30. Verify platform support and link type. A /32 identifies one host address rather than a two-endpoint link.
The address arithmetic helps with diagnosis, but operational platform behavior still matters. If a device rejects a prefix or handles routes unexpectedly, the correct next question is whether the interface and platform support the intended prefix semantics.
Allocate variable-length subnets without overlap
Suppose you own 10.20.0.0/24 for a lab and need four networks: 50 hosts, 20 hosts, 12 hosts and a two-endpoint routed link. Start with the largest ordinary host requirement. Fifty hosts need at least 52 addresses after reserving network and broadcast, so use /26 (64 total, 62 traditional usable). Twenty hosts need /27 (32 total, 30 usable). Twelve hosts need /28 (16 total, 14 usable). The routed pair can use /30 (four total, two traditional usable) unless a supported /31 point-to-point scheme is explicitly intended.
| Requirement | Allocation | Ordinary usable host range |
|---|---|---|
| 50 hosts | 10.20.0.0/26 |
10.20.0.1–10.20.0.62 |
| 20 hosts | 10.20.0.64/27 |
10.20.0.65–10.20.0.94 |
| 12 hosts | 10.20.0.96/28 |
10.20.0.97–10.20.0.110 |
| 2 hosts | 10.20.0.112/30 |
10.20.0.113–10.20.0.114 |
Check each boundary: the /26 ends at 63, the /27 at 95, the /28 at 111 and the /30 at 115. There is no overlap. The unused remainder of the /24 can be reserved for later expansion. Do not place a new /27 at .104 merely because 104 is beyond the last allocated host: a /27 must start on a multiple-of-32 boundary in the fourth octet.
Variable-length subnetting is an allocation problem as well as a calculation problem. Record the intended device count, growth headroom and routing plan before handing out prefixes; otherwise a technically valid set of subnets can still be a poor operational design.
Predict which traffic stays local
A host with 192.0.2.77/27 treats 192.0.2.80 as within its local /27, while 192.0.2.110 lies outside that block. For the first destination, the host can seek the link-layer destination directly when the interface and neighbor are reachable. For the second, the host typically sends the packet toward its configured default gateway unless a more specific route exists. The subnet calculation determines which forwarding decision it starts with; routing, VLAN transport, firewall policy and return routes determine whether the packet actually arrives.
This distinction is operationally important. If the source host believes a destination is local because of an incorrect /26 mask, it may try direct neighbor discovery where the network design expects a gateway. If the mask is correct but the VLAN trunk is not carrying the segment, the symptom may look similar even though the cause is different. Inspect the source prefix and actual L2/L3 paths before replacing a route.
Subnetting itself is not a complete security boundary. Separating clients into prefixes or VLANs can support segmentation, but policy enforcement also depends on routing, filtering and identity controls. Never claim that simply choosing smaller subnets provides access control.
Check your arithmetic with four practice problems
Work these on paper before checking the solutions:
- Find the network, broadcast and traditional usable range for
203.0.113.73/28. - Determine whether
192.0.2.62/26and192.0.2.65/26belong to the same subnet. - Find the network for
172.16.37.42/20and name the third-octet boundary after it. - Starting at
10.20.0.128, what is the first correctly aligned/27network at or after that point?
Answers: (1) /28 blocks contain 16 addresses; .73 is in 203.0.113.64–79, with network .64, broadcast .79 and ordinary hosts .65–.78. (2) No: .62 is in the .0–.63 /26, while .65 is in the .64–.127 /26. (3) 172.16.32.0/20; the next third-octet block starts at 48. (4) 10.20.0.128/27, because 128 is divisible by 32.
Notice what every solution has in common: locate the correct block boundary, calculate its size, then check that the supplied host falls inside it. The arithmetic is deterministic; most mistakes arise from applying it to the wrong octet or forgetting the alignment rule.
When a subnet plan fails in a real network
Before changing a router configuration, write down the host’s IP address, mask, default gateway, VLAN, expected remote prefix and actual route. Calculate the local network and test the gateway separately from the remote endpoint. Check the return path. For DHCP-assigned clients, verify the prefix and router option were delivered from the intended scope. For static clients, compare the configured mask with the documented segment.
If only name-based applications fail, subnetting may not be the cause: test resolution separately. If some remote networks work while one fails, inspect routing and filtering for that prefix. The point of becoming fluent in CIDR is not to avoid troubleshooting; it is to rule out addressing assumptions early so the rest of the diagnosis becomes more precise.
Retain an addressing plan that a second engineer can audit without asking you how you arrived at each boundary. That plan should show networks, masks, intended gateways, assigned pools and unused ranges. A correct subnet is one that is mathematically valid, nonoverlapping and operationally usable—not merely one that fits in a calculator.