What a subnet mask does and why you need to know it

A subnet mask is a number that tells your network which part of an IP address belongs to the network itself and which part identifies individual devices on that network. When you have an IP address like 192.168.1.50, the subnet mask determines whether that address is on the same local network as 192.168.1.100 or on a completely different one. Without knowing the subnet mask, you cannot tell which devices can talk to each other directly.

The subnet mask is not something you calculate from the IP address alone — it is assigned separately by whoever set up your network. However, you do need to understand how to read it, convert it between formats, and use it to figure out which addresses belong to the same network. This matters when you are troubleshooting network problems, setting up a router, or configuring a device to connect to a specific network.

Key Takeaways

  • A subnet mask is assigned to your network, not derived from the IP address, but you can learn to read and convert it between decimal and binary formats.
  • Subnet masks in decimal form (like 255.255.255.0) are easier to read if you convert each section to binary and count the consecutive 1s from the left.
  • CIDR notation (like /24) is a shorthand for subnet masks and tells you exactly how many bits belong to the network portion.
  • To find which devices are on the same network, use the subnet mask to calculate the network address and broadcast address for any given IP.
  • Common subnet masks like 255.255.255.0 (/24) and 255.255.0.0 (/16) cover different numbers of devices, so knowing which one your network uses changes how many addresses are available.

Understanding subnet mask notation: decimal versus binary

Subnet masks appear in two formats. The first is decimal notation, which looks like 255.255.255.0 — four numbers separated by dots, each between 0 and 255. The second is CIDR notation, which looks like /24 — a single slash followed by a number between 0 and 32. Both describe the same thing, just in different ways.

To convert decimal to CIDR, convert each decimal section to binary, then count how many 1s appear in a row from the left side. The number 255 in binary is 11111111 (eight 1s). The number 0 in binary is 00000000 (zero 1s). So 255.255.255.0 becomes 11111111.11111111.11111111.00000000, which has 24 consecutive 1s from the left — that is /24. A subnet mask of 255.255.0.0 becomes /16 because it has 16 ones followed by 16 zeros.

To convert CIDR back to decimal, write out that many 1s in binary, pad the rest with 0s to reach 32 bits total, then convert each group of 8 bits back to decimal. A /25 mask has 25 ones and 7 zeros: 11111111.11111111.11111111.10000000. The last section, 10000000, equals 128 in decimal, so /25 is 255.255.255.128.

How to calculate the network address using a subnet mask

The network address is the first address on a network segment — it identifies the network itself rather than a device. To find it, take your IP address and your subnet mask, convert both to binary, then perform a bitwise AND operation: wherever the subnet mask has a 1, keep the IP address bit; wherever the subnet mask has a 0, replace the IP address bit with 0.

Here is a concrete example. Suppose your IP is 192.168.1.50 and your subnet mask is 255.255.255.0. Convert to binary: 192.168.1.50 is 11000000.10101000.00000001.00110010, and 255.255.255.0 is 11111111.11111111.11111111.00000000. explore the AND operation: the first three sections stay the same (because the mask is all 1s), and the last section becomes all 0s (because the mask is all 0s). The result is 11000000.10101000.00000001.00000000, which is 192.168.1.0. That is your network address.

The network address tells you the starting point of your network range. Every device on that network will have an address between 192.168.1.0 and 192.168.1.255 (for a /24 network). The first address (192.168.1.0) is the network address itself and cannot be assigned to a device. The last address (192.168.1.255) is the broadcast address and also cannot be assigned to a device. Usable device addresses run from 192.168.1.1 to 192.168.1.254.

Finding the broadcast address and usable IP range

The broadcast address is the last address on a network segment. To find it, take your network address and replace all the host bits (the 0 bits in the subnet mask) with 1s. Using the same example: the network address is 192.168.1.0 and the subnet mask is 255.255.255.0. The last section of the subnet mask is 00000000, so all 8 bits are host bits. Replace them all with 1s: 192.168.1.255. That is your broadcast address.

Between the network address and broadcast address lies your usable range. For 192.168.1.0/24, that range is 192.168.1.1 through 192.168.1.254 — 254 usable addresses. A smaller network like 192.168.1.0/25 has a subnet mask of 255.255.255.128. The host bits are the last 7 bits (because 128 in binary is 10000000, leaving 7 zeros). The broadcast address is 192.168.1.127, and the usable range is 192.168.1.1 through 192.168.1.126 — only 126 addresses. A larger network like 192.168.0.0/16 has 65,534 usable addresses.

Common subnet masks and what they mean

Most home and small office networks use one of three subnet masks. A /24 mask (255.255.255.0) is the most common — it gives you 254 usable addresses on a single network segment. A /25 mask (255.255.255.128) splits a /24 network in half, giving you 126 usable addresses per segment. A /16 mask (255.255.0.0) is much larger and gives you 65,534 usable addresses, though it is rare in home networks.

Enterprise networks sometimes use /30 masks (255.255.255.252) for point-to-point links between routers — these provide only 2 usable addresses, which is exactly what you need when connecting two devices directly. A /32 mask (255.255.255.255) represents a single IP address with no other hosts on the network. Understanding which mask your network uses tells you when ready how many devices can coexist on the same segment without needing a router to separate them.

Using an IP calculator to verify your work

Once you understand the math, you can use an online IP subnet calculator to check your answers. These tools let you enter an IP address and subnet mask, then when ready show you the network address, broadcast address, usable range, and total number of hosts. They are useful for catching arithmetic errors and for working with unusual subnet masks like /23 or /27 that are harder to calculate by hand.

However, learning to do the calculation yourself matters because it builds your understanding of how networks actually work. A calculator tells you the answer; the math tells you why the answer is correct. When you troubleshoot a network problem, understanding why two devices cannot reach each other (because they are on different subnets) is more valuable than just knowing they cannot.

Frequently Asked Questions

Can I figure out the subnet mask just from looking at an IP address?

No. The IP address alone does not tell you the subnet mask. Two networks could use the same IP address range with different subnet masks — one might be 192.168.1.0/24 (254 hosts) and another might be 192.168.1.0/25 (126 hosts). The subnet mask must be provided by your network administrator or your router.

What is the difference between /24 and 255.255.255.0?

They are the same thing, just written differently. /24 is CIDR notation and means 24 bits for the network portion. 255.255.255.0 is decimal notation and represents the same 24 network bits. CIDR is shorter to type, while decimal is easier to read for people new to networking.

Why do some networks use /25 instead of /24?

A /25 network is half the size of a /24, so it supports fewer devices but uses IP addresses more efficiently. If you have two separate departments that do not need to talk to each other directly, splitting a /24 into two /25 networks lets you use one IP block for both without wasting addresses. It also improves network performance by reducing broadcast traffic.

How do I know if two IP addresses are on the same network?

Calculate the network address for both IPs using the same subnet mask. If both network addresses are identical, the IPs are on the same network and can reach each other directly. If the network addresses differ, the IPs are on different networks and need a router to communicate.

What happens if I use the wrong subnet mask?

Your device will not be able to reach other devices on the network, even if they are physically connected. It will try to send traffic directly to addresses it thinks are local, and those packets will never arrive. This is one of the most common configuration errors when setting up a new device on a network.