What Is a Subnet Mask? A Visual Guide to /24 and /26
A subnet mask marks which bits of an IP address name the network and which name the host. Slide the prefix to watch 255.255.255.0 (/24) become /26.
A subnet mask is a 32-bit pattern that splits an IPv4 address into a network part and a host part. The mask’s 1 bits mark the network, its 0 bits mark the host. 255.255.255.0 (written /24) means the first 24 bits name the network and the last 8 bits number up to 254 devices on it.
Network bits are filled; host bits are outlined.
11000000.10101000.00000001.1000001011111111.11111111.11111111.00000000- Subnet mask
- Network address
- Broadcast address
- Usable host range
- Usable hosts
- of addresses
Read the mask in binary
A mask only makes sense in binary, where it is always a run of 1s followed by a run of 0s:
| Mask | Binary | Prefix |
|---|---|---|
| 255.0.0.0 | 11111111.00000000.00000000.00000000 | /8 |
| 255.255.0.0 | 11111111.11111111.00000000.00000000 | /16 |
| 255.255.255.0 | 11111111.11111111.11111111.00000000 | /24 |
| 255.255.255.192 | 11111111.11111111.11111111.11000000 | /26 |
| 255.255.255.252 | 11111111.11111111.11111111.11111100 | /30 |
The prefix length after the slash is just the number of 1 bits. That shorthand is called CIDR notation. A pattern like 255.0.255.0 is not a valid mask, because its 1 bits are not contiguous; the calculator rejects it.
How a device uses the mask
To find its network, a device ANDs its address with the mask, bit by bit. Anything ANDed with 1 is kept and anything ANDed with 0 becomes 0, so the host bits are cleared:
address 192.168.1.130 11000000.10101000.00000001.10000010
mask /24 255.255.255.0 11111111.11111111.11111111.00000000
AND 192.168.1.0 11000000.10101000.00000001.00000000
It does the same with each destination. If the results match, the destination is on the same subnet and the packet is sent directly. If not, it goes to the default gateway (the router). A wrong mask breaks exactly this decision, which is one cause of the error covered in the ERR_ADDRESS_UNREACHABLE guide.
/24 explained
With 24 network bits, 8 bits are left for hosts: 2⁸ = 256 addresses.
- Network address: host bits all 0, 192.168.1.0. It names the subnet and is not given to a device.
- Broadcast address: host bits all 1, 192.168.1.255. Packets sent there reach every device on the subnet.
- Usable hosts: 192.168.1.1 to 192.168.1.254, which is 256 − 2 = 254.
Most home networks are a single /24 such as 192.168.0.0/24 or 192.168.1.0/24, taken from the private ranges set aside by RFC 1918.
/26 explained
Borrow two more bits for the network and the mask becomes 255.255.255.192 (the last byte is 11000000 = 128 + 64). Six host bits remain, so each subnet has 2⁶ = 64 addresses and 62 usable hosts. The two borrowed bits create four subnets inside the old /24:
| Subnet | Network | Usable range | Broadcast |
|---|---|---|---|
| 1 | 192.168.1.0 | .1 – .62 | 192.168.1.63 |
| 2 | 192.168.1.64 | .65 – .126 | 192.168.1.127 |
| 3 | 192.168.1.128 | .129 – .190 | 192.168.1.191 |
| 4 | 192.168.1.192 | .193 – .254 | 192.168.1.255 |
So 192.168.1.130/26 lives in the third block. Press /26 in the widget above to see the two extra network bits switch on.
Hosts per prefix
The rule is 2^(32 − prefix) addresses, minus 2 for the network and broadcast addresses:
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
Two exceptions: RFC 3021 allows /31 on point-to-point links, where both addresses are usable, and a /32 identifies a single host.
Subnet mask vs default gateway
The mask defines which addresses are local. The gateway is the router address used for everything else, and it must itself be inside the local subnet. The subnet calculator checks any address and mask, shows the network, broadcast and host range, and accepts either /26 or 255.255.255.192. IPv6 uses prefix lengths too (a typical LAN is a /64), but writes them only in CIDR form, never as a dotted mask; the IPv4 vs. IPv6 comparison covers the differences.
Sources
How we made this
Computed and checked by tests. All subnet figures come from src/lib/calc/subnet.js, which is shared with the subnet calculator and tested against values from Python's ipaddress module (for example 192.168.1.130/26 → 192.168.1.128–191, and 10.20.30.40/20 → 10.20.16.0/20).
Performed by Claude, an AI assistant working in the BinConvert repository (Node.js 25, Python 3.14.3), November 16, 2026.
This article was drafted with AI assistance. Every example, calculation and command output on this page was re-run or checked before release; every address in the tables was recomputed and cross-checked with Python's ipaddress module. Review: automated test suite and source check, November 16, 2026.
Spotted an error? Tell us and we will correct it.