What Is a Subnet Mask? IP Subnetting Explained
A subnet mask is a 32-bit number that divides an IP address into a network portion and a host portion. It determines which devices are on the same local network (subnet) without going through a router. Subnet masks are fundamental to IP networking and must be understood to design, troubleshoot, and secure networks.
How Subnet Masks Work
The subnet mask uses binary 1s to mark the network portion and 0s to mark the host portion. Example: 255.255.255.0 in binary is 11111111.11111111.11111111.00000000 — 24 network bits, 8 host bits. To find the network address: AND the IP with the mask. To find the broadcast: OR the network address with the inverted mask. All addresses between network and broadcast are usable hosts.
CIDR Notation
CIDR (Classless Inter-Domain Routing) notation appends /prefix-length to an IP address instead of writing the full mask. /24 = 255.255.255.0 (256 addresses, 254 usable). /16 = 255.255.0.0 (65,536 addresses). /32 = a single host. /0 = the entire internet. Common private ranges: 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12.
Calculating Hosts per Subnet
Usable hosts = 2^(host bits) − 2 (subtracting network address and broadcast address). /24: 2^8 − 2 = 254 usable hosts. /28: 2^4 − 2 = 14 usable hosts. /30: 2^2 − 2 = 2 usable hosts (used for point-to-point links). /31: 2 addresses, used for point-to-point per RFC 3021 with no broadcast. /32: single host.
Subnetting Example
Network: 192.168.10.0/24. Split into 4 equal subnets: borrow 2 bits → /26. Subnet 1: 192.168.10.0/26 (hosts .1–.62, broadcast .63). Subnet 2: 192.168.10.64/26 (hosts .65–.126, broadcast .127). Subnet 3: 192.168.10.128/26 (hosts .129–.190, broadcast .191). Subnet 4: 192.168.10.192/26 (hosts .193–.254, broadcast .255).