Given the IPv4 address 172.16.37.200/27, what are its network address, broadcast address, first and last usable hosts, and host count?
answer
- find the interesting octet
- mask octet is 224
- blocks of 32
- AND for network, all-ones host bits for broadcast
basics
~10 sFor 172.16.37.200/27 the mask is 255.255.255.224, blocks of 32 addresses: network 172.16.37.192, broadcast 172.16.37.223, usable hosts 172.16.37.193 to 172.16.37.222, which is 2^5 - 2 = 30 hosts.
solid answer
~40 sA /27 has 27 network bits, so the mask is `255.255.255.224` and the last octet keeps 5 host bits - blocks of 32. In binary, 200 is `11001000`; AND it with 224 (`11100000`) and you get `11000000` = 192, so the network address is `172.16.37.192`. Set the 5 host bits to one (OR with the inverse mask, 31) and you get 223, the broadcast `172.16.37.223`. The usable range is one above the network to one below the broadcast, `172.16.37.193` to `172.16.37.222`, and the count is `2^5 - 2 = 30`. The block-size shortcut agrees: the largest multiple of 32 not above 200 is 192, and 192 + 31 = 223.
code
pseudocode · 13 linesprefix = 27
addr = to_uint32(172.16.37.200)
mask = (0xFFFFFFFF << (32 - prefix)) AND 0xFFFFFFFF // 255.255.255.224
net = addr AND mask // 172.16.37.192
bcast = net OR (NOT mask AND 0xFFFFFFFF) // 172.16.37.223
if prefix <= 30:
first = net + 1 // 172.16.37.193
last = bcast - 1 // 172.16.37.222
hosts = 2^(32 - prefix) - 2 // 30
else if prefix == 31: // RFC 3021 point-to-point
first = net; last = bcast; hosts = 2
else: // /32, one address
first = net; last = net; hosts = 1go deeper
Know that a /27 mask is 255.255.255.224 and that a /27 holds 30 usable hosts; that alone gets you halfway through this question.
Show the AND in binary for the network, set the host bits for the broadcast, and cross-check with the multiples-of-32 shortcut, out loud and without a calculator.
Do it fast for any prefix, including when the interesting octet is the second or third, and use it to judge instantly whether two addresses share a subnet.
Treat fluency here as a baseline for reading address plans and incident data quickly; the judgment lies in what the boundaries imply for routing and filtering, not the arithmetic.
## What the prefix tells you A **/27** means the first 27 of the address's 32 bits are network bits and the last 5 are **host bits**. Written as a mask, that is 27 ones followed by 5 zeros: `11111111.11111111.11111111.11100000` = `255.255.255.224` The first three mask octets are 255, so the first three octets of the address, `172.16.37`, pass through unchanged into every answer. All the work happens in the fourth octet - the **interesting octet**, the one where the mask is neither 255 nor 0. ## Network address: bitwise AND 1. Write the interesting octet of the address in binary: 200 = `11001000`. 2. Write the mask octet in binary: 224 = `11100000`. 3. AND them bit by bit: `11000000` = 192. 4. Reassemble the address: the network address is **`172.16.37.192`**. AND keeps the network bits and clears the host bits, which is exactly the definition of the network address: the block's address with every host bit zero. ## Broadcast address: set every host bit The **directed broadcast address** is the block's address with every host bit one. OR the network address with the inverse of the mask, `0.0.0.31` (31 = `00011111`): `11000000` OR `00011111` = `11011111` = 223, so the broadcast is **`172.16.37.223`**. ## The whole answer in one table | Item | Last octet in binary | Address | |---|---|---| | Address given | `11001000` | 172.16.37.200 | | Mask | `11100000` | 255.255.255.224 | | Network (AND) | `11000000` | 172.16.37.192 | | First usable | `11000001` | 172.16.37.193 | | Last usable | `11011110` | 172.16.37.222 | | Broadcast (host bits all one) | `11011111` | 172.16.37.223 | | Usable hosts | - | 2^5 - 2 = 30 | The first usable host is the network address plus one and the last is the broadcast minus one; everything between is assignable, including the default gateway, which is just one of the 30. Putting the gateway on the first usable address (`172.16.37.193`) or the last (`172.16.37.222`) is a common site convention, not a protocol rule; IPv4 treats every one of the 30 the same. What the protocol does fix is the pair at the edges: a host on this subnet that sends to `172.16.37.223` is sending a directed broadcast to the whole /27, and `172.16.37.192` names the subnet rather than any machine on it. Mistaking either for a host address is how an address plan ends up with a "host" that never answers. ## The block-size shortcut Interviewers accept the shortcut provided you can show the bits behind it: - **Block size** = 256 - the interesting mask octet = 256 - 224 = 32, which is also 2^5. - /27 blocks start at multiples of 32 in that octet: 0, 32, 64, 96, 128, 160, 192, 224. - The network is the largest multiple not above 200: **192**. - The broadcast is the next block's start minus one: 224 - 1 = **223**. - Sanity checks: the given address lies between network and broadcast, and the network value is divisible by the block size. The same method works when the interesting octet is not the last one. For 172.16.37.200/20 the mask is `255.255.240.0`; the third octet has a block size of 16, so 37 falls in the block starting at 32, giving network `172.16.32.0`, broadcast `172.16.47.255` and 2^12 - 2 = 4,094 hosts. ## Mistakes that cost the answer - Answering `.0` and `.255` by reflex, as if every subnet were a /24. - An off-by-one on the mask: `255.255.255.240` is a /28, blocks of 16, which would give 172.16.37.192 to 172.16.37.207. - Including the network or broadcast address in the usable range, or claiming 32 hosts. - Rounding *up* to 224, which is the next subnet's network address, not this one's. - Applying the minus-two rule to a /31 or /32, where it does not hold.
- Is 172.16.37.180 in the same IPv4 /27 subnet as 172.16.37.200?No. AND both with 224: 180 is `10110100`, giving `10100000` = 160, while 200 gives 192. Different network addresses mean different subnets: 172.16.37.180 belongs to 172.16.37.160/27, usable .161 to .190, broadcast .191. A host on 172.16.37.192/27 would send traffic for it to its gateway rather than deliver it directly.
- What changes if the same IPv4 address, 172.16.37.200, carries a /20 instead of a /27?The interesting octet moves to the third: the mask is 255.255.240.0, block size 16, so 37 falls in the block starting at 32. Network 172.16.32.0, broadcast 172.16.47.255, usable 172.16.32.1 to 172.16.47.254, and 2^12 - 2 = 4,094 hosts. Addresses ending in .0 or .255 inside that range are ordinary hosts.
saying these in an interview costs you the question
- The network address of 172.16.37.200/27 is 172.16.37.0.
- Every subnet's broadcast address ends in .255.
- A /27 has 32 usable hosts.
- The usable range includes the network and broadcast addresses.
- The mask for a /27 is 255.255.255.240.