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

  1. A /26 mask is 255.255.255.192: 26 network bits, 6 host bits.
  2. 6 host bits give 26 = 64 addresses per subnet, so the subnets start at .0, .64, .128 and .192.
  3. .130 falls in the block starting at .128: network address 192.168.1.128.
  4. The last address of the block, 192.168.1.191, is the broadcast.
  5. Usable hosts: .129 to .190, which is 62 hosts (64 minus network and broadcast).

Check any example instantly with the subnet calculator.

Quick reference

CIDRMaskUsable hostsTypical use
/16255.255.0.065,534large campus or VPC
/24255.255.255.0254home and office LANs
/26255.255.255.19262small departments, VLANs
/29255.255.255.2486small static IP blocks from ISPs
/30255.255.255.2522router-to-router links
/31255.255.255.2542 (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.0 are invalid.

More network tools

Guides