Saved

Utilix knowledge base

What Is a Subnet Mask? Explained With Examples

By Utilix Editorial Team · Published Oct 3, 2026

What Is a Subnet Mask?

A subnet mask is a 32-bit number that tells a device which part of an IPv4 address identifies the network and which part identifies the host. A device compares its own address and the mask to decide whether another address is on the local network or must be reached through a router.

The most common subnet mask is 255.255.255.0. For a device at 192.168.1.25, it means 192.168.1 is the network and .25 is the host.

How a subnet mask works

A mask is a run of 1 bits followed by a run of 0 bits. The 1 bits mark the network portion; the 0 bits mark the host portion.

255.255.255.0

11111111.11111111.11111111.00000000
└──────── network (24) ───┘└ host (8) ┘

Masks must be contiguous — all the 1s first, then all the 0s. 255.255.0.255 is not a valid subnet mask.

Subnet mask and CIDR notation

The same mask is often written as a prefix length: the count of 1 bits. 255.255.255.0 is /24. See What Is CIDR? for the notation itself.

Subnet maskCIDRTotal addressesUsable hosts
255.0.0.0/816 777 21616 777 214
255.255.0.0/1665 53665 534
255.255.255.0/24256254
255.255.255.128/25128126
255.255.255.192/266462
255.255.255.224/273230
255.255.255.240/281614
255.255.255.248/2986
255.255.255.252/3042

Usable hosts = 2^(host bits) − 2. One address is the network address and one is the broadcast address.

Worked example: find the network address

A device has the address 192.168.1.130 and the mask 255.255.255.192 (/26). To find its network, apply a bitwise AND between the address and the mask.

Address  192.168.1.130  = 11000000.10101000.00000001.10000010
Mask     255.255.255.192 = 11111111.11111111.11111111.11000000
AND                      = 11000000.10101000.00000001.10000000
                         = 192.168.1.128   ← network address

From there:

  • Network address: 192.168.1.128
  • Broadcast address: 192.168.1.191 (all host bits set to 1)
  • Usable range: 192.168.1.129 – 192.168.1.190 (62 hosts)

Two devices can talk directly only if the AND of their addresses with the mask gives the same network address. Otherwise, traffic goes to the default gateway.

Subnet mask vs wildcard mask

A wildcard mask is the inverse of the subnet mask. It is used in Cisco ACLs and OSPF configuration. The wildcard for 255.255.255.0 is 0.0.0.255. See What Is CIDR? for a conversion table.

How to choose a subnet mask

  1. Count the hosts the subnet needs, including growth.
  2. Add 2 for the network and broadcast addresses.
  3. Round up to the next power of two. That gives the number of host bits.
  4. The prefix length is 32 minus the host bits.

For 50 devices: 50 + 2 = 52, round up to 64 = 2⁶, so 6 host bits and a /26 (255.255.255.192). For splitting a larger block into several of these, see How Subnetting Works.

Common mistakes

  • Mismatched masks on one segment. Devices with different masks disagree about who is local, which causes one-way connectivity.
  • Gateway outside the subnet. The default gateway must be inside the same subnet as the host.
  • Forgetting the two reserved addresses. A /30 has 4 addresses but only 2 usable hosts.
  • Assuming classful defaults. Class A/B/C masks are legacy; modern networks use any prefix length (CIDR).

FAQ

What is the subnet mask of 192.168.1.1?

There is no mask built into the address. Home networks typically use 255.255.255.0 (/24) with 192.168.1.x addresses, but the mask is a configuration setting. Check your router or run ipconfig (Windows) or ip addr (Linux).

What does 255.255.255.0 mean?

It means the first 24 bits are the network and the last 8 bits are the host. That gives 256 addresses in the subnet and 254 usable hosts.

What is the difference between a subnet mask and CIDR?

They describe the same boundary. A subnet mask writes it as four decimal numbers (255.255.255.0); CIDR writes the count of network bits (/24).

How do I calculate a subnet mask from a number of hosts?

Add 2 to the host count, round up to the next power of two, and take the exponent as the host bits. The prefix length is 32 minus that number. For 100 hosts: 102 rounds up to 128 = 2⁷, giving /25 (255.255.255.128).

Can two devices with different subnet masks communicate?

Sometimes, but unreliably. Each device decides independently what is local, so one may send directly while the other sends via the gateway. Use the same mask for every device on a segment.

Related tools