If you have ever opened your network settings and seen 255.255.255.0 next to your IP address, you have met a subnet mask. It looks like an IP address, but it is not one — it is a filter that tells your computer which part of an address names the network and which part names the device.
What a subnet mask actually does
Every device on a network has an IP address, a set of four numbers like 192.168.1.42. The problem is that the address alone does not say where the network ends and the device begins. Is 192.168.1.42 on the same network as 192.168.2.42, or a different one? The subnet mask answers that question. It is a second set of four numbers laid over the address: wherever the mask has a 255, that part of the address belongs to the network; wherever it has a 0, that part belongs to the individual device.
Think of it like a postal address. The street name tells you the neighborhood, and the house number tells you the building. A subnet mask is the rule that says which words are the street and which are the house number. With the classic home mask 255.255.255.0, the first three numbers (192.168.1) are the network and the last number (42) is the device. Two devices whose first three numbers match are neighbors on the same local network; if the first three numbers differ, traffic has to go through a router to get between them.
Reading 255.255.255.0, bit by bit
Under the hood, an IP address is 32 ones and zeros, and a subnet mask is 32 ones and zeros too. The mask is always a run of ones followed by a run of zeros — never mixed. The ones mark the network portion; the zeros mark the host portion. The dotted-decimal number 255.255.255.0 is just the human-friendly way to write 24 ones followed by 8 zeros: 11111111.11111111.11111111.00000000.
That is why the mask always looks like a string of 255s and then a string of 0s (with an occasional 128, 192, 224, 240, 248, or 252 in the middle when the split falls inside a number). A mask like 255.255.255.128 means 25 ones and 7 zeros — the network extends one bit into the last number. If you ever see a mask that is not a clean run of ones then zeros, something is misconfigured.
CIDR notation: the /24 shorthand
Network engineers got tired of writing out four numbers, so they invented CIDR notation: a slash followed by the count of ones in the mask. The mask 255.255.255.0 has 24 ones, so it is written /24. The address 192.168.1.42 with that mask becomes 192.168.1.42/24. This one number tells you everything the full mask does.
Here are the masks you will meet most often:
- /8 — 255.0.0.0 — the first number is the network; more than 16 million host addresses. The old "Class A" size.
- /16 — 255.255.0.0 — the first two numbers are the network; 65,534 usable hosts. The old "Class B" size.
- /24 — 255.255.255.0 — the first three numbers are the network; 254 usable hosts. The standard home and small-office network.
- /25 — 255.255.255.128 — half a /24; 126 usable hosts. Two /25 networks fit in one /24.
- /30 — 255.255.255.252 — just 2 usable hosts; used for the link between two routers.
- /32 — 255.255.255.255 — a single address, used to identify one specific host.
How many hosts fit in a network?
The host count comes from the zeros in the mask. Each zero bit doubles the number of addresses, so a mask with 8 host bits gives 2^8 = 256 addresses. But two of those addresses are always reserved: the all-zeros address is the network address itself (192.168.1.0), and the all-ones address is the broadcast address (192.168.1.255) used to shout at every device at once. That leaves 254 usable host addresses — the classic reason a home network tops out at 254 devices.
The formula is simple: usable hosts = 2^(number of host bits) − 2. For a /25 network there are 7 host bits, so 2^7 − 2 = 126 usable hosts. For a /16 there are 16 host bits, so 65,534. This is the math behind every "how many devices can I connect?" question, and it is also why running out of addresses on a growing office network means re-masking to a larger block, not just plugging in more hardware.
Worked example: the network 192.168.1.0/24
Take a typical home network, 192.168.1.0/24. The mask says the network portion is 192.168.1 and the host portion is the last number. The usable range runs from 192.168.1.1 (usually the router) to 192.168.1.254. The network address 192.168.1.0 and the broadcast address 192.168.1.255 are off-limits for devices.
Now imagine a second network, 192.168.2.0/24. A device at 192.168.1.42 wants to talk to 192.168.2.42. It compares the network portions using its mask, sees they differ, and sends the packet to its default gateway — the router — which forwards it to the other network. If the mask were /16 instead (255.255.0.0), the same two devices would consider themselves on one network, 192.168.0.0/16, and would talk directly without a router. Same addresses, different mask, completely different behavior. That is the mask's real power: it defines the boundary of "local."
Why subnetting exists at all
In the early internet, every organization got one big block of addresses and every device on it shared one broadcast domain — one device's broadcast chatter reached every other device. As networks grew, that became noisy and insecure: a misbehaving device could flood thousands of machines, and there was no way to wall off departments from each other.
Subnetting fixes this by carving one big block into smaller networks. A company with a /16 block can split it into 256 separate /24 networks — one per floor, one per department, one for guests, one for printers. Each subnet gets its own broadcast domain, its own security rules, and its own address space. Traffic between subnets passes through a router, which can filter it. The internet itself works this way: it is a hierarchy of subnets, from a home /24 up to the huge blocks that ISPs route between continents.
The common mistakes
Most subnet problems come from a handful of errors. The most common is typing the wrong mask on a device — 255.255.0.0 instead of 255.255.255.0, for example — which makes the device think distant addresses are local, so it never sends traffic to the gateway and connections silently fail. Another is assigning a device the network address or the broadcast address (the .0 or .255 in a /24), which other devices treat as the whole network, not one machine. A third is overlapping subnets: two networks that claim the same address range, so routers cannot tell them apart. When a device can reach some addresses but not others on what should be the same network, the mask is the first thing to check.
Frequently asked questions
What is 255.255.255.0 in simple terms?
It is a subnet mask that says the first three numbers of an IP address name the network and the last number names the device. Written as CIDR notation it is /24, and it allows 254 usable devices on one network. It is the default mask on almost every home router.
How do I calculate how many hosts a subnet supports?
Count the host bits — the zeros in the mask — then use the formula 2 raised to that power, minus 2. The minus 2 accounts for the network address and the broadcast address, which cannot be assigned to devices. For a /24 there are 8 host bits, so 2^8 − 2 = 254 usable hosts.
What is the difference between a subnet mask and CIDR notation?
They describe the same thing in two formats. A subnet mask like 255.255.255.0 spells out the network and host portions in four numbers, while CIDR notation like /24 just counts the ones in the mask — 24 in this case. CIDR is shorter to write and is what you will see in router configs and cloud settings.
Can two devices with the same IP address be on different subnets?
Yes. The same address in two different subnets is a different location, because the mask decides which part of the address is the network. That is exactly why subnetting works: 10.0.0.5 on one company's /24 and 10.0.0.5 on another's are unrelated, and routers keep them apart.