A subnet mask tells a device which part of an IP address is the network and which part is the device. Without it, no device would know whether another address is local or far away. Here is the full explanation, including CIDR.
Published 28 November 2026 • SHM Soft
You have seen IP addresses like 192.168.1.10. You have probably also seen a number next to them, like 255.255.255.0. That second number is the subnet mask, and it is just as important as the address itself. Without it, a device cannot tell where its own network ends and the rest of the world begins.
In this guide, we explain what a subnet mask is, how it works in binary, what the common masks mean, and how CIDR notation gives you a shorter way to write the same thing. No maths degree needed. We take it one small step at a time.

A subnet mask is a 32-bit number, written in the same dotted form as an IPv4 address, that splits an IP address into two parts: the network part and the host part. The 1 bits in the mask mark the network part. The 0 bits mark the host part. Every device on a network uses its mask to work out which network it belongs to, and whether another address is on the same network or a different one.
Take the address 192.168.1.10 with the mask 255.255.255.0. The mask is 24 ones followed by 8 zeros. That means the first 24 bits, the first three numbers, are the network: 192.168.1. The last 8 bits are the host: 10. Any address starting with 192.168.1 is on the same network. An address starting with anything else is on a different network, and the device sends it to its default gateway instead.
That decision is the mask's whole job. A computer compares its own address with the destination address, using the mask, and asks one question: same network or different network? If it is the same, the computer talks directly. If it is different, the computer sends the packet to the router and lets the router handle it. Every packet you have ever sent went through this quiet little check.
Masks in binary
To really understand masks, you need to see them in binary. The mask 255.255.255.0 is 11111111.11111111.11111111.00000000. The mask 255.255.255.192 is 11111111.11111111.11111111.11000000. Notice the rule: the ones always come first, in one unbroken block, and the zeros always come after. A valid mask never mixes them up. That is why only nine values can appear in any octet of a mask: 0, 128, 192, 224, 240, 248, 252, 254, and 255.
When a device checks an address, it performs a simple AND operation between the address and the mask. Bits that line up with a 1 stay, and bits that line up with a 0 become 0. The result is the network address. It is fast, it is simple, and it happens for every packet, thousands of times a second, on every device on the network.
Common subnet masks
A few masks cover most of what you will ever see. The mask 255.0.0.0, or /8, leaves 24 host bits, which is over 16 million addresses. It is the old Class A default. The mask 255.255.0.0, or /16, leaves 16 host bits, which is 65,534 usable addresses. The mask 255.255.255.0, or /24, leaves 8 host bits, which is 254 usable addresses, and it is the most common mask on small networks. Then come the small ones: /25 gives 126 usable addresses, /26 gives 62, /27 gives 30, /28 gives 14, /29 gives 6, and /30 gives 2, which is just right for a link between two routers.
If you are learning subnetting, these numbers are worth memorising. They come up constantly, and knowing them by heart makes every subnetting question faster. The pattern is simple: each extra mask bit halves the number of hosts. Learn the /24 to /30 range first, and the rest follows.
Writing 255.255.255.192 every time gets old fast. CIDR notation, which stands for Classless Inter-Domain Routing, replaces the whole mask with one number: the count of 1 bits. The mask 255.255.255.0 has 24 ones, so you write /24. The mask 255.255.255.192 has 26 ones, so you write /26. The address and the mask become one short string, like 192.168.1.0/24.
CIDR is how networks are written everywhere today: in router configs, in cloud consoles, in firewall rules, and in exam questions. It is shorter, it is harder to mistype, and it makes the size of a network obvious at a glance. A /24 is 256 addresses. A /16 is 65,536. A /28 is 16. Once you know the pattern, you can read a CIDR prefix the way you read a street name.
To convert between the two forms, count the ones. A /20 mask is 20 ones and 12 zeros, which is 11111111.11111111.11110000.00000000, or 255.255.240.0. To go the other way, turn each octet into binary and count the ones. It is a useful exercise the first few times, and then you will just know the common ones by heart.
A wrong mask causes confusing faults. If the mask is too long, the device thinks its own network is smaller than it is, and it sends local traffic to the router for no reason. If the mask is too short, the device thinks distant addresses are local, and it tries to reach them directly instead of using the gateway. Either way, some things work and some things do not, which makes the fault hard to spot.
The classic symptom is a computer that can reach some devices but not others, or a computer that works fine on its own subnet but cannot reach the internet. The first thing to check is always the mask, the gateway, and the address itself. These three must agree, or nothing else will make sense. Our guide on what an IP address is explains the address side, and our guide on what DHCP is explains how most devices get their address and mask automatically, which is why a wrong mask usually means a wrong DHCP setting, not a typing mistake.
On a home network, the mask is almost always 255.255.255.0, and you never need to think about it. On a business network, masks vary by department and site, and getting them right is part of the design. If two devices that should talk cannot, check the mask before you blame the cable.

Do not confuse a subnet mask with a wildcard mask. They look similar, but they mean the opposite. In a subnet mask, a 1 means this bit is part of the network. In a wildcard mask, used in Cisco access lists and OSPF network statements, a 0 means this bit must match, and a 1 means this bit can be anything. A /24 subnet mask is 255.255.255.0. The matching wildcard mask is 0.0.0.255. Mixing them up is a classic exam mistake, and a classic real-world mistake too.
IPv6 handles masks differently, and more simply. An IPv6 address is 128 bits long, and it is always written with CIDR notation, like /64. There is no dotted-decimal mask in IPv6. The first 64 bits are usually the network, and the last 64 bits are the device. You still need to know the prefix length, but you never write out a 128-bit mask by hand. If you want the full story, read our guide on what IPv6 is and why we need it.
One more thing worth knowing: the mask does not have to match the old address classes. In the early days, addresses starting with 192 always used a /24 mask, and addresses starting with 10 always used a /8 mask. CIDR ended that. Today any address can use any mask, which is exactly what makes subnetting possible. The class system is history, but the mask is still the tool that does the work.
Watch on YouTube: Subnet Mask - Explained
A quick way to remember the common masks
Remember the host counts, not the mask numbers. A /24 has 254 usable hosts. A /25 has 126. A /26 has 62. A /27 has 30. A /28 has 14. A /29 has 6. A /30 has 2. Each step halves the number. If you know the /24 and the halving rule, you can work out any of them in seconds, and you can check your own subnetting answers without a calculator.
The same rule works in reverse. If you need 50 usable addresses, the smallest mask that fits is /26, with 62. If you need 100, you need /25, with 126. Always round up to the next size that fits, and always remember the two reserved addresses. A subnet that looks big enough on paper is one address short if you forget them.
What is a subnet mask in simple terms?
A subnet mask is a number that tells a device which part of an IP address identifies the network and which part identifies the device. It draws the line between the two parts.
What does 255.255.255.0 mean?
It means the first three parts of the address are the network, and the last part is the device. In CIDR notation, it is written as /24. A network with this mask has 256 addresses and 254 usable ones.
What is CIDR notation?
CIDR notation writes a subnet mask as a slash and a number, like /24. The number counts how many bits of the address belong to the network. It is a shorter, clearer way to write the same information as a dotted mask.
What is the difference between a subnet mask and a wildcard mask?
They are opposites. In a subnet mask, a 1 means the bit is part of the network. In a wildcard mask, a 0 means the bit must match and a 1 means it can vary. A /24 subnet mask is 255.255.255.0, and its wildcard mask is 0.0.0.255.
Do I need a subnet mask on a home network?
Yes, but you never have to set it yourself. Your router gives your devices the mask 255.255.255.0 automatically through DHCP, and that is right for almost every home.
Conclusion
A subnet mask is a small number that does a big job. It tells every device where its network ends, which addresses are local, and which ones need the router. Without it, an IP address is just a number with no meaning. With it, the whole system of networks, subnets, and routing falls into place.
Learn the common masks, learn CIDR, and remember the halving rule. A /24 gives 254 hosts, and every extra bit halves that number. Once that clicks, subnetting, routing, and troubleshooting all get easier, because the mask is the piece they all share.
Related articles:
What Is Subnetting? A Beginner's Guide
How one network is split into smaller subnets, step by step, with a worked example.
What Is an IP Address? A Complete Beginner's Guide
What an IP address is, public vs private, and how devices use them to find each other.
What Is IPv6 and Why Do We Need It?
The 128-bit successor to IPv4, and why the internet is slowly moving to it.
Want a clear price for your project?
Tell us what you need and we will send a free quote with no hidden charges.