Why Two Addresses in Every Subnet Are Reserved
Every IPv4 subnet reserves exactly two addresses that cannot be assigned to an individual host device: the network address (the lowest address in the range, identifying the subnet itself rather than any specific host within it) and the broadcast address (the highest address in the range, used to send a single packet to every host on that subnet simultaneously). This is why usable host count is always 2 less than the subnet's total address count — 2^(host bits) total addresses, minus these 2 reserved addresses.
The Network Address: Bitwise AND
The network address is calculated by taking the IP address and the subnet mask, converting both to binary, and performing a bitwise AND operation bit by bit — wherever the mask has a 1 (a network bit), the result keeps the IP's original bit value; wherever the mask has a 0 (a host bit), the result is forced to 0 regardless of what the IP's original bit was. The practical effect: the network address is the given IP address with every host bit set to zero, representing the "base" of that subnet's address range.
The Broadcast Address: Bitwise OR with the Wildcard
The broadcast address is calculated similarly but using the wildcard mask (the bitwise inverse of the subnet mask — every 1 becomes 0 and every 0 becomes 1) combined with a bitwise OR operation: wherever the wildcard mask has a 1 (corresponding to a host bit in the original subnet mask), the result is forced to 1; wherever the wildcard mask has a 0 (a network bit), the result keeps the IP's original bit. The practical effect: the broadcast address is the given IP address with every host bit set to one, representing the "top" of that subnet's address range.
Working Through a Full Binary Example
For 192.168.1.100/26 (a /26 mask has 6 host bits): converting the last octet, 100, to binary gives 01100100. The /26 subnet mask's last octet is 11000000 (192 in decimal) — the top 2 bits are network bits, the bottom 6 are host bits. Applying AND: 01100100 AND 11000000 = 01000000 (64 in decimal) — so the network address is 192.168.1.64. Applying the wildcard (00111111, or 63 in decimal) with OR: 01100100 OR 00111111 = 01111111 (127 in decimal) — so the broadcast address is 192.168.1.127. The usable host range for this subnet is therefore 192.168.1.65 through 192.168.1.126.
Why This Matters Beyond Manual Calculation
Understanding the underlying bitwise logic — rather than just trusting a calculator's output — matters for troubleshooting real network problems: recognizing when a configured IP address is actually the network or broadcast address of its subnet (a common misconfiguration that can cause a device to fail to communicate, since neither address is valid for a host), verifying that a proposed subnet boundary doesn't accidentally overlap an adjacent subnet, and reading a router's routing table or ACL entries (which are frequently expressed using network address and either a CIDR prefix or an explicit wildcard mask) with real comprehension rather than by memorized pattern alone.
Why Subnetting Tools Automate This, Not Replace Understanding It
A subnet calculator (like this site's IP Subnet Calculator) performs exactly these bitwise AND/OR operations automatically and instantly — genuinely useful for speed and to avoid manual arithmetic errors on larger or less "round" prefix lengths. But understanding the underlying binary logic remains valuable specifically because it's what lets a network engineer sanity-check a calculator's output, catch a misconfigured address in a live network without needing to run a tool, and reason correctly about edge cases (like the /31 point-to-point exception, covered in the companion VLSM article) where the standard network/broadcast reservation logic is deliberately modified.