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
| Prefix | Subnet mask | Total addresses | Usable hosts | Typical use |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 | Standard LAN segment |
| /25 | 255.255.255.128 | 128 | 126 | Half a /24 |
| /26 | 255.255.255.192 | 64 | 62 | Small office / VLAN |
| /27 | 255.255.255.224 | 32 | 30 | Device management |
| /28 | 255.255.255.240 | 16 | 14 | Tiny segment |
| /30 | 255.255.255.252 | 4 | 2 | Point-to-point links |
| /31 | 255.255.255.254 | 2 | 2 | P2P links (RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 | Host 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 .255The 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:
- What subnet does host
172.16.35.123/20belong to? - How many /29 subnets fit in a /24, and how many usable hosts does each have?
- Two routers need a link network. What's the most address-efficient prefix?
Answers
- 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).
- /24 → /29 borrows 5 bits: 32 subnets, each with 2³ − 2 = 6 usable hosts.
- /31 (RFC 3021) — both addresses usable, nothing wasted. Use /30 only if the platform doesn't support /31 on point-to-point links.