IPv4 subnetting basics: reading an address and a prefix
What /24 means, how network and broadcast addresses are found, and how to size a subnet for a number of devices.
· Awaiting human editorial review
An address is 32 bits
An IPv4 address such as 192.168.1.130 is four 8-bit numbers. A prefix such as /26 says how many of the leading bits identify the network; the remaining bits identify a host within it. A /26 leaves 6 host bits, so the subnet contains 2⁶ = 64 addresses.
The same split can be written as a subnet mask: 26 one-bits followed by six zero-bits, which is 255.255.255.192.
Network and broadcast addresses
The network address is found by setting all host bits to zero (a bitwise AND of the address and the mask). For 192.168.1.130/26 that is 192.168.1.128. The broadcast address sets all host bits to one: 192.168.1.191. Hosts can use the addresses in between, so this subnet has 62 usable host addresses.
Two special cases: a /31 is used for point-to-point links and both addresses are usable (RFC 3021), and a /32 identifies a single host.
Sizing and summarising
To fit a given number of devices, find the smallest prefix whose usable host count is large enough — 500 hosts need a /23 (510 usable). Leave room for growth.
When writing firewall rules for a range that does not start on a neat boundary, you may need several CIDR blocks. The CIDR calculator splits any range into the minimal list of blocks.