CompSci.rocks
LearnNetworking

Subnetting Practice Problems

Learn the manual method for IPv4 subnetting, then practice with randomly generated problems across five difficulty levels and instant feedback.

Subnetting shows up on every networking exam and in real network design, and the only way to get fast at it is to work a lot of problems. Pick a difficulty below and start practicing — if you need a refresher on the manual method first, it's covered step by step further down the page. Prefer working from paper instead of a screen, or need a set of problems to hand out to a whole class? This IPv4 subnetting worksheet generator builds a printable version of the same kind of problem.

Subnetting Practice

Work out the network address, broadcast address, first and last usable hosts, and the number of usable hosts for the address shown, then click Check Answers.

If you'd rather just check your work than solve it by hand, the subnet calculator will give you the same values instantly.

How to subnet an IPv4 address by hand

Every IPv4 address is 32 bits, split into a network portion and a host portion by the subnet mask (or its CIDR prefix, like /26). The number of host bits determines the size of the subnet — everything else follows from that.

Step 1 — Find the block size. The block size is how many addresses are in each subnet, and it comes from the host bits: 2^(host bits). It's easiest to work with the last non-255, non-zero octet of the subnet mask: block size = 256 - mask octet. A /26 mask is 255.255.255.192, so the block size in the last octet is 256 - 192 = 64.

Step 2 — Find the network address. Subnets in that octet start at 0 and count up by the block size: 0, 64, 128, 192, and so on. The network address is whichever multiple of the block size the given IP address falls into — round the relevant octet down to the nearest multiple of the block size, and set every octet after it to 0.

Step 3 — Find the broadcast address. The broadcast address is one less than the next network address, so add the block size to the network's octet and subtract 1, setting every octet after it to 255.

Step 4 — Find the usable host range. The first usable address is the network address plus 1, and the last usable address is the broadcast address minus 1. Everything else in the subnet is off-limits — the network and broadcast addresses can't be assigned to a device.

Step 5 — Count the usable hosts. That's the block size minus 2, one for the network address and one for the broadcast address.

Worked example

Let's subnet 192.168.1.130 /26.

  • Mask: 255.255.255.192, so the block size is 256 - 192 = 64.
  • The interesting octet is the third-to-last... actually the last octet here, since the mask only touches the last octet. Multiples of 64 are 0, 64, 128, 192. The address's last octet is 130, which falls between 128 and 192, so it belongs to the 128 subnet.
  • Network address: 192.168.1.128
  • Next network address is 192.168.1.192, so the broadcast address is 192.168.1.191
  • First usable host: 192.168.1.129
  • Last usable host: 192.168.1.190
  • Usable hosts: 64 - 2 = 62

The same steps work no matter which octet the mask lands in — a /18 mask lands in the third octet, a /10 mask lands in the second octet — you're just applying the block-size math to a different position in the address.

Quick reference

CIDR Subnet mask Block size Usable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
Classful defaults, for reference: Class A networks use a /8 mask (255.0.0.0), Class B networks use a /16 mask (255.255.0.0), and Class C networks use a /24 mask (255.255.255.0). Any CIDR prefix longer than the classful default is that network broken into smaller subnets.

Common mistakes to watch for

  • Forgetting to round down. The network address always rounds the relevant octet down to the nearest multiple of the block size, never up.
  • Off-by-one on the broadcast address. It's the next network address minus 1, not the current network address plus the block size.
  • Mixing up which octet the mask lands on. For anything shorter than a /24, the interesting math happens in an earlier octet than the last one — write out the mask in binary if you're not sure where the network/host boundary falls.
  • Counting the network and broadcast address as usable. They're part of the subnet, but never assigned to a device (except for /31 links, which skip both).

Once you're comfortable with Easy problems, move up to Medium and Hard — those mix in Class A and B networks, where the subnetting math happens outside the last octet. When you want to double-check a specific address without generating a random problem, the subnet calculator shows the same five values plus the wildcard mask and binary breakdown. And once this all feels routine, the next step is VLSM practice — the same math, applied to fitting several differently-sized subnets into one address block.