What is a subnet mask?
A subnet mask splits an IP address into a network part and a host part. Devices with the same network part talk directly; everything else goes through the router.
Mask and CIDR are the same information
The mask 255.255.255.0 in binary is 24 ones followed by 8 zeros, so it is written /24 in CIDR notation. The ones mark network bits, the zeros host bits. The more ones, the smaller the network.
Worked example: 192.168.1.130/26
- A
/26mask is255.255.255.192: 26 network bits, 6 host bits. - 6 host bits give 26 = 64 addresses per subnet, so the subnets start at .0, .64, .128 and .192.
- .130 falls in the block starting at .128: network address
192.168.1.128. - The last address of the block,
192.168.1.191, is the broadcast. - Usable hosts:
.129to.190, which is 62 hosts (64 minus network and broadcast).
Check any example instantly with the subnet calculator.
Quick reference
| CIDR | Mask | Usable hosts | Typical use |
|---|---|---|---|
| /16 | 255.255.0.0 | 65,534 | large campus or VPC |
| /24 | 255.255.255.0 | 254 | home and office LANs |
| /26 | 255.255.255.192 | 62 | small departments, VLANs |
| /29 | 255.255.255.248 | 6 | small static IP blocks from ISPs |
| /30 | 255.255.255.252 | 2 | router-to-router links |
| /31 | 255.255.255.254 | 2 (RFC 3021) | point-to-point links |
Wildcard masks
Access lists on Cisco and other routers use the wildcard mask, the bitwise inverse of the subnet mask: 255.255.255.0 becomes 0.0.0.255. The calculator shows both.
Common mistakes
- Giving a device the network or broadcast address. They are reserved in every subnet larger than /31.
- Two devices with the same network but different masks: one thinks the other is local, the other sends traffic to the router.
- Non-contiguous masks such as
255.0.255.0are invalid.