Networking · 5 min read

Subnetting basics

A subnet is a slice of an IP network. Subnetting lets you split one big network into smaller ones, so devices are grouped and traffic stays where it belongs.

Network part vs host part

An IPv4 address is 32 bits. The subnet mask says how many of those bits identify the network. The rest identify individual hosts.

CIDR notation writes the mask as a number of bits. 192.168.1.0/24 means the first 24 bits are the network, which is the same as the mask 255.255.255.0.

Cheat sheet

CIDRMaskAddressesUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/30255.255.255.25242

Formula: usable hosts = 2^(32 − prefix) − 2. You subtract 2 because the first address is the network address and the last is the broadcast address.

The block-size trick

Take the interesting octet of the mask (the one that isn't 255 or 0) and subtract it from 256. That's the block size, and subnets start at every multiple of it.

/26 → mask octet 192 → 256 − 192 = 64. Subnets start at .0, .64, .128 and .192.

Worked example: 192.168.10.0/26

SubnetNetworkUsable rangeBroadcast
1.0.1 – .62.63
2.64.65 – .126.127
3.128.129 – .190.191
4.192.193 – .254.255

Practice

Which subnet does 10.0.5.77/27 belong to? Hint: the block size is 32.

Show answer

Network 10.0.5.64, usable .65 – .94, broadcast .95.

← Back to all notes