Networking

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.

Try itDrag the prefix or press /24 and /26. Filled bits are network, outlined bits are host.

Network bits are filled; host bits are outlined.

Address11000000.10101000.00000001.10000010
Mask11111111.11111111.11111111.00000000
Subnet mask
255.255.255.0
Network address
192.168.1.0
Broadcast address
192.168.1.255
Usable host range
192.168.1.1 – 192.168.1.254
Usable hosts
254 of 256 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:

MaskBinaryPrefix
255.0.0.011111111.00000000.00000000.00000000/8
255.255.0.011111111.11111111.00000000.00000000/16
255.255.255.011111111.11111111.11111111.00000000/24
255.255.255.19211111111.11111111.11111111.11000000/26
255.255.255.25211111111.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:

SubnetNetworkUsable rangeBroadcast
1192.168.1.0.1 – .62192.168.1.63
2192.168.1.64.65 – .126192.168.1.127
3192.168.1.128.129 – .190192.168.1.191
4192.168.1.192.193 – .254192.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:

PrefixMaskAddressesUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242

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

  1. RFC 950: Internet Standard Subnetting Procedure — IETF
  2. RFC 4632: Classless Inter-domain Routing (CIDR) — IETF
  3. RFC 1918: Address Allocation for Private Internets — IETF
  4. RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links — IETF

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.

Copied to clipboard!