Opens in a new tab

IPv4 Subnet Trainer

IPv4 Reverse Subnetting Trainer

Find the smallest classic IPv4 subnet that safely fits a required number of usable hosts.

Hosts → smallest subnet

Classic IPv4 model: one network address and one broadcast address are reserved. /31 and /32 are intentionally excluded from host-capacity exercises.

Smallest prefix /27
Mask 255.255.255.224
Addresses total 32
Usable hosts 30
Host bits 5
27 + 2 = 29 → 32 = 2^5 → 32 − 5 = /27

Universal algorithm

  1. Take the required number of usable hosts and add 2.
  2. Round up to the nearest power of two.
  3. The exponent is the number of host bits.
  4. Prefix = 32 − host bits.
  5. Check that the resulting usable-host capacity is large enough.
HOSTS + 2 → next 2^n → 32 − n = prefix
Quick reference
Required hosts Prefix Mask Usable hosts
1–2/30255.255.255.2522
3–6/29255.255.255.2486
7–14/28255.255.255.24014
15–30/27255.255.255.22430
31–62/26255.255.255.19262
63–126/25255.255.255.128126
127–254/24255.255.255.0254
255–510/23255.255.254.0510
511–1022/22255.255.252.01022