Subnet masks explained: what /24 means and how to size a network

Your laptop's IP is 192.168.1.37 with a subnet mask of 255.255.255.0, or in modern notation 192.168.1.37/24. Those two numbers together say which addresses are neighbours (reachable directly) and which are elsewhere (reachable via the router). The arithmetic is binary and short, and once seen it stops being mysterious. The subnet calculator does it; this guide explains it.

Network part, host part

An IPv4 address is 32 bits, written as four decimal bytes. The mask says how many of those bits, from the left, identify the network; the rest identify the host within it. In 192.168.1.37/24 the first 24 bits (192.168.1) are the network and the last 8 (.37) the host. Two addresses with the same network bits are on the same subnet and talk directly; different network bits mean a router in between. Binary, explained from zero covers the binary; the binary translator shows any address as bits.

The mask and the /prefix

The mask is the same idea written as 32 bits of 1s followed by 0s: /24 is 11111111.11111111.11111111.00000000 = 255.255.255.0. /16 is 255.255.0.0; /8 is 255.0.0.0. Non-byte boundaries are where people get lost: /26 is 255.255.255.192 (192 = 11000000), /27 is .224, /28 is .240, /30 is .252. CIDR notation (Classless Inter-Domain Routing, 1993) replaced the old class A/B/C scheme so networks could be any size; the /prefix is simply the count of 1 bits.

How many hosts fit

With h host bits there are 2h addresses, minus two: the all-zeros address names the network itself and the all-ones is the broadcast. So a /24 has 256 addresses and 254 usable hosts; a /25 has 126; a /26, 62; a /27, 30; a /28, 14; a /30, 2 (the classic point-to-point link); a /16, 65,534. Going the other way: a network for 40 devices needs 6 host bits (2โถ โˆ’ 2 = 62), so a /26. The calculator gives the network address, first and last usable host, broadcast and count for any address and prefix.

Private ranges and the home router

Three ranges are reserved for private use and never routed on the internet (RFC 1918): 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Home routers hand out addresses from a /24 inside one of them โ€” usually 192.168.0.x or 192.168.1.x โ€” and translate them to the one public address the ISP gives (NAT). That's why every house has a 192.168.1.1 and why two devices in different homes can share an address without conflict. 127.0.0.0/8 is loopback (yourself), 169.254.0.0/16 is what a device assigns itself when no DHCP answers โ€” the signature of a broken connection.

Planning subnets

Splitting a network into subnets isolates traffic (guests from staff, cameras from laptops), limits broadcast noise and makes firewall rules possible. Take a /24 and split it: two /25s (128 each), or four /26s, or a /25 for staff and two /26s for guests and devices. Subnets must align to their size โ€” a /26 starts at .0, .64, .128 or .192, never .100 โ€” which is the error the calculator catches. Leave room to grow: a subnet at 90% is a migration waiting to happen. IPv6 makes the arithmetic bigger and simpler at once: 128-bit addresses, a /64 per network as standard, and more addresses per subnet than atoms in the room. The hex viewer and number base converter help when reading the packed forms; the port reference covers the other half of an address.

Sources and further reading

The claims in this guide rest on these references, which were checked when the guide was last updated. Spotted an error? The contact page says how to report it.

  1. Subnet โ€” Wikipedia
  2. RFC 1918: Address Allocation for Private Internets

Try the tool

Frequently asked questions

What does /24 mean?

The first 24 bits of the address identify the network and the remaining 8 the host โ€” the same as a mask of 255.255.255.0. It holds 256 addresses, 254 usable.

How many hosts can a /26 have?

62 โ€” six host bits give 64 addresses, minus the network and broadcast addresses.

Why is 192.168.1.1 my router?

192.168.0.0/16 is a private range never routed on the internet; home routers use a /24 within it and take the first address for themselves.

Why must a subnet start at .64 or .128?

Subnets align to their size in binary. A /26 (64 addresses) can only begin on a multiple of 64; a /25 on a multiple of 128.