Subnet Mask

A 32-bit value that tells a device which portion of an IPv4 address identifies the network and which portion identifies the host.

Last updated:

What is a subnet mask?

A subnet mask is a 32-bit value paired with an IPv4 address to divide the address into a network portion and a host portion. The mask is a run of 1-bits followed by a run of 0-bits. When a device wants to send a packet, it applies a bitwise AND between the destination IP and the mask to determine whether the destination is on the same local network (same network portion) or needs to be routed through a gateway.

The most common home-network mask is 255.255.255.0, which means: the first 24 bits are the network, the last 8 bits are the host, and up to 254 devices can share this subnet (256 addresses minus 1 for the network address and 1 for the broadcast address).

Common subnet masks

| Mask | Prefix | Usable Hosts | |-------------------|--------|-------------:| | 255.0.0.0 | /8 | 16,777,214 | | 255.255.0.0 | /16 | 65,534 | | 255.255.255.0 | /24 | 254 | | 255.255.255.128 | /25 | 126 | | 255.255.255.192 | /26 | 62 | | 255.255.255.252 | /30 | 2 |

Subnet masks vs. CIDR notation

CIDR notation is a shorthand for the same information. 192.168.1.0/24 is equivalent to 192.168.1.0 with mask 255.255.255.0. CIDR replaced subnet masks in most modern documentation because it's more compact, but network equipment, operating systems, and older documentation still use the dotted-decimal mask form.

Why subnetting matters

Subnetting lets network administrators split a large block into smaller, independently routed segments — for example, separating a guest Wi-Fi network from a corporate LAN, or isolating servers, printers, and IoT devices. Smaller subnets also shrink broadcast domains, which improves performance on Ethernet-like links.

Our subnet calculator converts between masks, CIDR prefixes, and host counts.

Frequently Asked Questions

It is a subnet mask that says "the first three bytes of the IP address are the network, the last byte is the host." Equivalently written as `/24` in CIDR notation. A network with this mask has 256 total addresses (0-255 in the host byte), with 254 usable for devices — the first (`.0`) is the network address and the last (`.255`) is the broadcast address. This is the default mask on most home routers.
Start with the number of devices you need on a single subnet, add 2 for the network and broadcast addresses, round up to the next power of 2, and subtract that exponent from 32 to get the prefix length. For 50 devices: 50 + 2 = 52, next power of 2 is 64 (2^6), prefix length = 32 - 6 = /26, mask = 255.255.255.192. Our subnet calculator tool does this conversion in both directions and shows the host range.
The subnet mask tells your device which destination IPs are on the same local network (deliver directly via Layer 2) and which are not (send to the gateway for routing). The default gateway is the router IP your device sends every off-subnet packet to. The two work together: the mask decides "is this destination local or remote?", and the gateway is the answer for the "remote" case.
Two addresses in every IPv4 subnet are reserved by convention. The first address (all host bits zero, e.g. `192.168.1.0`) is the network address — used as a label for the subnet itself, not assigned to any device. The last address (all host bits one, e.g. `192.168.1.255`) is the broadcast address — packets sent to it are delivered to every device in the subnet. Assigning a host either of these would cause routing confusion.
Yes — they describe identical subnet boundaries in two different formats. `/24` is the CIDR shorthand for a 24-bit network prefix (24 leading 1-bits in the mask). `255.255.255.0` is the same 24 leading 1-bits expressed in dotted decimal. Modern equipment and documentation favor the CIDR form because it is more compact, but operating system network settings and older guides still use the full mask.