Skip to content

Subnetting Basics

Last updated:

Subnetting is just borrowing: you take host bits from an IPv4 address and lend them to the network portion. Master the powers of two and you can do all of it in your head.

CIDR quick reference

PrefixSubnet maskTotal addressesUsable hostsTypical use
/24255.255.255.0256254Standard LAN segment
/25255.255.255.128128126Half a /24
/26255.255.255.1926462Small office / VLAN
/27255.255.255.2243230Device management
/28255.255.255.2401614Tiny segment
/30255.255.255.25242Point-to-point links
/31255.255.255.25422P2P links (RFC 3021)
/32255.255.255.25511Host route / loopback

Usable hosts = 2ⁿ − 2 (network + broadcast), except /31 point-to-point links where both addresses are usable.

The binary view

Splitting 192.168.10.0/24 into four /26 subnets means borrowing 2 host bits:

text
/24:  11000000.10101000.00001010.| 00000000   network | hosts
/26:  11000000.10101000.00001010.00| 000000   borrowed ↑↑

Subnet 0: 192.168.10.0/26    hosts .1 – .62,    broadcast .63
Subnet 1: 192.168.10.64/26   hosts .65 – .126,  broadcast .127
Subnet 2: 192.168.10.128/26  hosts .129 – .190, broadcast .191
Subnet 3: 192.168.10.192/26  hosts .193 – .254, broadcast .255

The block size is always 256 − last mask octet (here 256 − 192 = 64), so subnet boundaries land on multiples of 64.

Choosing a prefix

The IPv4 address space at a glance

Practice

Work these out before expanding the answers:

  1. What subnet does host 172.16.35.123/20 belong to?
  2. How many /29 subnets fit in a /24, and how many usable hosts does each have?
  3. Two routers need a link network. What's the most address-efficient prefix?
Answers
  1. A /20 has a block size of 16 in the third octet. 35 falls in the 32–47 block, so the subnet is 172.16.32.0/20 (hosts .32.1 – .47.254, broadcast 172.16.47.255).
  2. /24 → /29 borrows 5 bits: 32 subnets, each with 2³ − 2 = 6 usable hosts.
  3. /31 (RFC 3021) — both addresses usable, nothing wasted. Use /30 only if the platform doesn't support /31 on point-to-point links.