Skip to content
OneKitly

How Subnet Masks Work: CIDR, Network Bits, and Usable Hosts

Published 11/20/2025 · 4 min read · Developer tools

Daniel Okonkwo

Daniel OkonkwoFront-end developer and tech writer at OneKitly

Web performance · File formats

Checked against 2 sources

View profile
In short

A subnet mask marks which bits of an IP address identify the network and which identify the host. In CIDR notation, /24 means the first 24 bits are the network, leaving 8 bits for hosts. Those 8 host bits give 256 addresses, but two are reserved (network and broadcast), so a /24 has 254 usable host addresses.

Understand how a subnet mask splits an IP address into network and host parts, what /24 means, and how to count usable hosts.

Network bits versus host bits

An IPv4 address is 32 bits, usually written as four numbers from 0 to 255, like 192.168.1.10. A subnet mask is also 32 bits, but it is a run of 1s followed by a run of 0s. The 1s mark the network portion — the part every device on the same subnet shares — and the 0s mark the host portion, which is unique to each device.

For the mask 255.255.255.0, the first three bytes are all 1s (24 ones) and the last byte is all 0s. So in 192.168.1.10 the 192.168.1 part is the network and the 10 is the host. Any device whose address starts with 192.168.1 sits on the same subnet and can talk directly; anything else must go through a router.

What /24 and CIDR notation mean

Writing masks as 255.255.255.0 is clumsy, so CIDR notation simply counts the network bits after a slash. /24 means 24 network bits, which is exactly 255.255.255.0. A /16 means 16 network bits (255.255.0.0) and a /8 means 8 (255.0.0.0). The bigger the number after the slash, the more bits are locked to the network and the fewer are left for hosts.

This flexibility is the point of CIDR: you are not stuck with whole bytes. A /26 borrows two host bits for the network, splitting a /24 into four smaller subnets of 64 addresses each. Sizing subnets this way lets you match the address space to how many devices a segment actually needs, instead of wasting a full /24 on a handful of machines.

Counting usable hosts

The number of addresses in a subnet is 2 raised to the number of host bits. A /24 has 8 host bits, so 2 to the 8 is 256 addresses. But the first address (all host bits 0) is the network identifier and the last (all host bits 1) is the broadcast address, and neither can be assigned to a device. That leaves 256 minus 2, or 254 usable hosts.

The same formula scales to any prefix: a /26 has 6 host bits, so 64 addresses and 62 usable hosts; a /30 has 2 host bits, so 4 addresses and just 2 usable hosts — handy for point-to-point links. A subnet calculator does this instantly, showing the network address, broadcast address, host range, and total usable hosts for any CIDR you enter.

Subnet calculator (CIDR)Compute the subnet mask and number of usable hosts from a CIDR prefix.Try the tool

Frequently asked questions

Why are two addresses always reserved?
The address with all host bits set to 0 names the subnet itself and cannot belong to a single machine, while the address with all host bits set to 1 is the broadcast address used to reach every host at once. Because both have special meaning, neither is available to assign, which is why usable hosts equal total addresses minus 2.
How do I know if two IPs are on the same subnet?
Apply the same mask to both addresses and compare the network portions. If the bits covered by the mask are identical, they share a subnet and can communicate without a router. For 192.168.1.10 and 192.168.1.200 with a /24, both start with 192.168.1, so they are on the same subnet.
Does IPv6 use subnet masks too?
IPv6 uses the same CIDR prefix idea, but addresses are 128 bits instead of 32, so a typical subnet is a /64. The concept of network bits and host bits is identical; there is just far more address space, so IPv6 rarely worries about running out of usable hosts within a subnet.
What is the difference between a /24 and a /25?
A /25 borrows one more bit for the network than a /24, so it has 7 host bits instead of 8. That halves the subnet: 128 addresses and 126 usable hosts instead of 254. Splitting a /24 into two /25s gives you two separate networks, each isolated from the other unless a router connects them.

Articles you may find interesting

All guides

Related tools

Sources

Spotted a mistake in this article?

How Subnet Masks Work: CIDR, Network Bits, and Usable Hosts — OneKitly