A subnet mask is a 32-bit number used in IPv4 networking that logically separates an IP address into its network and host components. The mask uses binary AND logic: bits set to 1 identify the network or subnet portion, while bits set to 0 identify the host portion.
How It Works
When a subnet mask is applied to an IP address, each bit position is ANDed together. For example, the IP address 192.168.1.10 with subnet mask 255.255.255.0 (also written as /24 in CIDR notation) produces:
| Component | Value |
|---|---|
| IP Address | 192.168.1.10 |
| Subnet Mask | 255.255.255.0 |
| Network Address | 192.168.1.0 |
| Usable Host Range | 192.168.1.1–192.168.1.254 |
| Broadcast Address | 192.168.1.255 |
RFC 950 recommends that subnet mask bits be contiguous (all 1s followed by all 0s), though non-contiguous masks are technically legal. Modern networks use CIDR notation (e.g., /24, /16) for clarity.
When It Matters
Subnet masks are essential for routers and devices to determine whether traffic should stay on the local network or be forwarded elsewhere. They're also used in Dynamic DNS configurations and network planning.
IPv6 does not use subnet masks; it uses prefix-length notation exclusively (e.g., /64).
WarningLegacy systems may reject the all-zeros subnet (e.g., 192.168.1.0/25), though modern CIDR-compliant routing accepts it. Always verify equipment compatibility when using edge cases.