What Is a Subnet Mask? Networking Basics Explained

The binary math behind network segmentation — explained clearly with practical examples

Understanding Subnet Masks

A subnet mask is a 32-bit number that works alongside an IP address to define the boundary between the network portion and the host portion of that address. In plain English: it tells your device and router which part of an IP address identifies the network, and which part identifies a specific device within that network.

Subnet masks are written in the same dotted-decimal notation as IP addresses. The most common values you'll encounter are:

In binary, a subnet mask is always a series of consecutive 1s followed by 0s. The 1 bits mark the network portion; the 0 bits mark the host portion. For example:

255.255.255.0 in binary:
11111111.11111111.11111111.00000000
|--- network (24 bits) ---|hosts(8)|

This is why 255.255.255.0 is also written as /24 in CIDR notation — 24 bits are the network portion.

How Subnet Masks Define Network Boundaries

When a device wants to communicate with another IP address, it uses the subnet mask to determine whether the destination is on the same local network (and can be reached directly) or on a different network (requiring a router).

The device performs a bitwise AND operation between its own IP address and its subnet mask, and does the same for the destination IP. If both results are the same, the destination is on the same network.

Example: Your device has IP 192.168.1.50 with mask 255.255.255.0. Is 192.168.1.100 on the same network?

192.168.1.50  AND 255.255.255.0 = 192.168.1.0  (your network)
192.168.1.100 AND 255.255.255.0 = 192.168.1.0  (same network!)
→ Direct communication, no router needed

Now test 192.168.2.50:

192.168.2.50  AND 255.255.255.0 = 192.168.2.0  (different network)
→ Must send through router (default gateway)

This calculation happens automatically every time your device sends a packet. The subnet mask is central to how all IP networking works at the most fundamental level.

🛡️

Look Up Any IP Address

Our free tool reveals full network details for any IP address instantly.

Hide My IP Now

Network Address, Broadcast Address, and Usable Hosts

Every subnet has three special addresses you need to understand:

Network address: All host bits set to 0. This identifies the subnet itself and cannot be assigned to a device. For 192.168.1.0/24, the network address is 192.168.1.0.

Broadcast address: All host bits set to 1. Used to send messages to all devices on the subnet simultaneously. Cannot be assigned to a device. For 192.168.1.0/24, the broadcast is 192.168.1.255.

Usable host range: Everything in between. For a /24, that's 192.168.1.1 through 192.168.1.254254 usable host addresses.

General formula: hosts = 2n - 2, where n is the number of host bits. Common examples:

Variable Length Subnet Masking (VLSM)

Originally, IP networks used fixed subnet masks based on address class. Modern networking uses VLSM (Variable Length Subnet Masking), allowing network administrators to choose any prefix length from /1 to /32, creating subnets of precisely the size needed.

VLSM is the foundation of CIDR. It allows efficient IP address allocation by right-sizing each subnet. For example, a network with these requirements:

VLSM allows these different-sized subnets to coexist within a larger address block without waste, compared to the old classful approach of allocating identical fixed-size blocks regardless of need.

Understanding subnet masks is essential background knowledge before tackling our CIDR notation guide, which covers the shorthand prefix notation in depth.

Finding Your Subnet Mask

Your subnet mask is configured on your network interface, usually assigned automatically by your router via DHCP. To find it:

Windows: Run ipconfig in Command Prompt. Look for "Subnet Mask" under your active adapter.

Mac: System Settings → Network → your connection → Details → TCP/IP tab. Shows "Subnet Mask" in dotted-decimal.

Linux: Run ip addr show — the prefix length appears after the IP address (e.g., 192.168.1.5/24 where /24 = 255.255.255.0).

Router admin panel: Access your router at its gateway IP (see our router IP guide) and check LAN settings.

For most home networks you'll see 255.255.255.0 (/24) — indicating a 254-device capacity local network, which is more than sufficient for typical households.

Special Offer

Frequently Asked Questions

What does 255.255.255.0 mean as a subnet mask?

It means the first three octets (24 bits) of the IP address identify the network, and the last octet (8 bits) identifies the host. On a 192.168.1.0/24 network, all devices from 192.168.1.1 to 192.168.1.254 are on the same local network and can communicate directly without going through a router.

What is a /32 subnet mask?

A /32 mask (255.255.255.255) means the entire 32-bit address is the network portion — there are no host bits. This identifies a single specific host. It's used in routing tables to create host routes or specify a single IP address precisely.

What's the difference between a subnet mask and a wildcard mask?

A subnet mask uses 1s to indicate the network portion. A wildcard mask (used in Cisco ACLs and OSPF configurations) is the bitwise inverse — 0s indicate matched bits and 1s indicate 'don't care' bits. A /24 subnet mask (255.255.255.0) has a wildcard mask of 0.0.0.255.

Can subnet masks be any value?

No. A valid subnet mask must be a contiguous series of 1 bits followed by 0 bits in binary. Values like 255.255.255.64 are invalid because they'd produce a non-contiguous pattern. Valid masks follow the pattern of consecutive 1s: 128, 192, 224, 240, 248, 252, 254, 255 are the only valid values for any octet.

Special Offer×