Networking

Subnetting Practice Set: 25 Problems with Full Solutions

Subnetting is one of those skills where reading about it gets you 30% of the way and doing it gets you the other 70%. The first time someone hands you an address with a non-obvious prefix and asks “is .142 a usable host on this network?” the math has to feel reflexive, not like a puzzle. The fastest way to get there is repetition.

This is lesson 13 of Networking from Scratch — the deep-dive companion to lesson 3, which introduced the magic-number method. This article is twenty-five problems, ranging from warm-up classful boundaries to real-world VLSM planning, with full solutions for every one. Work through them in order; by problem 25 you will be subnetting in your head.

Quick refresher: the four-line method

Before we start, the entire procedure compressed into four lines:

magic       = 256 - (the relevant octet of the subnet mask)
network     = round the address octet down to a multiple of magic
broadcast   = network + magic - 1
next subnet = network + magic

And the lookup table for what every mask octet means:

Mask octet Bits set Magic (256−value)
0 0 256
128 1 128
192 2 64
224 3 32
240 4 16
248 5 8
252 6 4
254 7 2
255 8 1

Two more facts you’ll lean on constantly:

  • Total addresses in a /N = 2^(32-N).
  • Usable hosts = total − 2 (subtract the network ID and the broadcast). Exception: /31 point-to-point (RFC 3021) and /32 host route both have all addresses usable.

Now the practice. For each problem: try it yourself first, then check against the solution. Time yourself if you like — the goal is <30 seconds per problem by problem 15.

Tier 1: classful warm-up (problems 1–5)

These are the “the prefix lands on a dot” cases. They’re here so the procedure becomes muscle memory before things get harder.

Problem 1

What is the network ID, broadcast, first / last usable host, and next subnet for 192.168.1.42/24?

Solution. Mask /24 = 255.255.255.0. Interesting octet: 4th. Mask value there: 0.

magic       = 256 - 0   = 256
network     = round 42 down to a multiple of 256 = 0
broadcast   = 0 + 256 - 1 = 255
next subnet = 0 + 256 = 256 (carries to next 3rd-octet value)

Answer: network 192.168.1.0, broadcast 192.168.1.255, first host .1, last host .254, next subnet 192.168.2.0. (256 addresses, 254 usable.)

Problem 2

Same questions for 10.50.20.7/8.

Solution. Mask /8 = 255.0.0.0. Interesting octet: 2nd. Mask value: 0.

magic       = 256 - 0 = 256
network     = round 50 (2nd octet) down to a multiple of 256 = 0
broadcast   = 0 + 256 - 1 = 255 (in the 2nd octet, but we also need .255.255.255)

Answer: network 10.0.0.0, broadcast 10.255.255.255, first host 10.0.0.1, last host 10.255.255.254, next subnet 11.0.0.0. (16,777,216 addresses, 16,777,214 usable — the entire 10.0.0.0/8 private space.)

Problem 3

For 172.20.5.99/16: network and broadcast.

Solution. Mask /16 = 255.255.0.0. Interesting octet: 3rd. Mask value: 0. Magic = 256.

The first 16 bits (172.20) are network; the rest is host. So everything from the 3rd octet on is host.

Answer: network 172.20.0.0, broadcast 172.20.255.255, first host 172.20.0.1, last host 172.20.255.254, next subnet 172.21.0.0. (65,536 addresses, 65,534 usable.)

Problem 4

Is 192.168.10.255 a usable host on the network 192.168.10.0/24?

Solution. A /24 has 256 addresses. The first (.0) is the network ID; the last (.255) is the broadcast. Neither is usable.

Answer: No. .255 is the broadcast address.

Problem 5

How many usable hosts fit in 10.0.0.0/16?

Solution. A /16 has 2^16 = 65,536 addresses. Usable = 65,536 - 2 = 65,534.

Answer: 65,534.

Tier 2: /25 to /30 inside the 4th octet (problems 6–10)

Now we’re slicing inside the last octet. The interesting octet is still the 4th, but the magic number stops being 256.

Problem 6

Network and broadcast for 192.168.1.130/25.

Solution. /25 = 255.255.255.128. Interesting octet: 4th. Mask value: 128.

magic       = 256 - 128 = 128
network     = round 130 down to a multiple of 128 = 128
broadcast   = 128 + 128 - 1 = 255
next subnet = 128 + 128 = 256 (carries to the next /25 in the next /24)

Answer: network 192.168.1.128, broadcast 192.168.1.255, first host .129, last host .254. (128 addresses, 126 usable.)

Problem 7

Network and broadcast for 10.0.0.65/26.

Solution. /26 = 255.255.255.192. Magic = 256 - 192 = 64.

Round 65 down to a multiple of 64. Multiples of 64: 0, 64, 128, 192. Largest one ≤ 65 is 64.

network     = 64
broadcast   = 64 + 64 - 1 = 127
next subnet = 64 + 64 = 128

Answer: network 10.0.0.64, broadcast 10.0.0.127, first host .65, last host .126. (64 addresses, 62 usable.)

Problem 8

Network and broadcast for 172.16.5.99/27.

Solution. /27 = 255.255.255.224. Magic = 256 - 224 = 32.

Multiples of 32: 0, 32, 64, 96, 128. Largest ≤ 99 is 96.

network     = 96
broadcast   = 96 + 32 - 1 = 127
next subnet = 96 + 32 = 128

Answer: network 172.16.5.96, broadcast 172.16.5.127, first host .97, last host .126. (32 addresses, 30 usable.)

Problem 9

Network and broadcast for 192.168.5.85/28.

Solution. /28 = 255.255.255.240. Magic = 16. Multiples of 16: 0, 16, 32, 48, 64, 80, 96. Largest ≤ 85 is 80.

network     = 80
broadcast   = 80 + 16 - 1 = 95
next subnet = 80 + 16 = 96

Answer: network 192.168.5.80, broadcast 192.168.5.95, first host .81, last host .94. (16 addresses, 14 usable.)

Problem 10

Network and broadcast for 10.20.30.130/30. Is .130 a usable host?

Solution. /30 = 255.255.255.252. Magic = 4. Multiples of 4: 128, 132, 136. Largest ≤ 130 is 128.

network     = 128
broadcast   = 128 + 4 - 1 = 131
next subnet = 128 + 4 = 132

So the subnet is 10.20.30.128 - 10.20.30.131. Network is .128, broadcast is .131, usable hosts are .129 and .130.

Answer: Yes, .130 is one of the two usable hosts. (The other is .129.)

Tier 3: across an octet boundary (problems 11–15)

Now the prefix doesn’t land on a dot. The interesting octet is no longer the 4th — it shifts left.

Problem 11

Network and broadcast for 10.5.79.200/22.

Solution. /22 = 255.255.252.0. Interesting octet: 3rd (because the 4th is all zeros and the first two are all ones). Mask value in the 3rd octet: 252. Magic = 256 - 252 = 4.

Round the 3rd octet (79) down to a multiple of 4. Multiples of 4: 76, 80. 76.

Octets to the left of the interesting one don’t change. Octets to the right are 0 in the network and 255 in the broadcast.

network     = 10.5.76.0
broadcast   = 10.5.(76+4-1).255 = 10.5.79.255
next subnet = 10.5.(76+4).0 = 10.5.80.0

Answer: network 10.5.76.0, broadcast 10.5.79.255, first host 10.5.76.1, last host 10.5.79.254, next subnet 10.5.80.0. (1,024 addresses, 1,022 usable.)

Problem 12

Network and broadcast for 192.168.130.50/20.

Solution. /20 = 255.255.240.0. Interesting octet: 3rd. Mask value: 240. Magic = 16.

Round the 3rd octet (130) down to a multiple of 16. Multiples of 16 near 130: 112, 128, 144. Largest ≤ 130 is 128.

network     = 192.168.128.0
broadcast   = 192.168.(128+16-1).255 = 192.168.143.255
next subnet = 192.168.144.0

Answer: network 192.168.128.0, broadcast 192.168.143.255, first host 192.168.128.1, last host 192.168.143.254. (4,096 addresses, 4,094 usable.)

Problem 13

Network and broadcast for 172.16.200.10/17.

Solution. /17 = 255.255.128.0. Interesting octet: 3rd. Mask value: 128. Magic = 128.

Round the 3rd octet (200) down to a multiple of 128. Multiples: 0, 128, 256. Largest ≤ 200 is 128.

network     = 172.16.128.0
broadcast   = 172.16.(128+128-1).255 = 172.16.255.255
next subnet = 172.17.0.0  (carries up because 128+128 = 256)

Answer: network 172.16.128.0, broadcast 172.16.255.255, first host 172.16.128.1, last host 172.16.255.254. (32,768 addresses, 32,766 usable.)

Problem 14

Network and broadcast for 10.10.10.10/15.

Solution. /15 = 255.254.0.0. Interesting octet: 2nd (the 3rd and 4th are zero, the first is all ones). Mask value: 254. Magic = 2.

Round the 2nd octet (10) down to a multiple of 2. 10 already is one. 10.

network     = 10.10.0.0
broadcast   = 10.(10+2-1).255.255 = 10.11.255.255
next subnet = 10.12.0.0

Answer: network 10.10.0.0, broadcast 10.11.255.255, first host 10.10.0.1, last host 10.11.255.254. (131,072 addresses, 131,070 usable.)

Problem 15

Two hosts, 10.5.79.200 and 10.5.80.5, both with mask /22. Are they on the same subnet?

Solution. Use the result from problem 11: 10.5.79.200/22 is on subnet 10.5.76.0/22 (range .76.0 through .79.255). Now check the second host: 10.5.80.5/22.

3rd octet = 80; magic = 4; multiples 76, 80, 84; largest <= 80 is 80
network = 10.5.80.0/22 (range .80.0 through .83.255)

Answer: No. The first is on 10.5.76.0/22, the second on 10.5.80.0/22. They’re neighbours but not the same subnet, and they’d need a router between them to talk.

Tier 4: VLSM — carving a block into pieces (problems 16–20)

Variable Length Subnet Masking is the practical version of subnetting: given a parent block, slice it into smaller subnets of different sizes for different uses. The procedure is always: biggest first, fit each one into the next free space.

Problem 16

Carve 10.0.0.0/24 into four equal-sized subnets. What are they?

Solution. Four equal subnets means each gets 1/4 of the addresses. /24 has 256; each new subnet has 64; that’s a /26. Magic = 64.

Walk through in steps of 64:

Subnet Range Usable
10.0.0.0/26 .0 - .63 62
10.0.0.64/26 .64 - .127 62
10.0.0.128/26 .128 - .191 62
10.0.0.192/26 .192 - .255 62

Problem 17

You have 192.168.10.0/24. You need three subnets, sized for: 100 hosts, 50 hosts, 20 hosts. Plan the addressing.

Solution. Round each requirement up to the next prefix that fits. Refer to the host counts:

  • 100 hosts → need /25 (126 usable).
  • 50 hosts → need /26 (62 usable).
  • 20 hosts → need /27 (30 usable).

Place biggest first in the parent block, fitting each into the next free space.

Subnet Range Hosts allowed Need
192.168.10.0/25 .0 - .127 126 100
192.168.10.128/26 .128 - .191 62 50
192.168.10.192/27 .192 - .223 30 20
(unused) .224 - .255 30 spare

That extra /27 at the top can be saved for future growth.

Problem 18

Carve 10.10.10.0/24 for: a server tier (60 hosts), a workstation tier (60 hosts), a printer tier (10 hosts), and 4 router-to-router links (2 hosts each).

Solution. Round up each requirement:

  • 60 hosts → /26 (62 usable).
  • 60 hosts → another /26.
  • 10 hosts → /28 (14 usable).
  • 2 hosts → /30 (2 usable). 4 links = 4 of these.

Largest first:

Subnet Range Use
10.10.10.0/26 .0 - .63 Servers
10.10.10.64/26 .64 - .127 Workstations
10.10.10.128/28 .128 - .143 Printers
10.10.10.144/30 .144 - .147 Link 1
10.10.10.148/30 .148 - .151 Link 2
10.10.10.152/30 .152 - .155 Link 3
10.10.10.156/30 .156 - .159 Link 4
(unused) .160 - .255 spare /27 + /26

Problem 19

You inherit a network where someone used 192.168.0.0/24 for everything — servers, workstations, IoT, guests — on one flat segment. They want to subdivide into four equal segments without renumbering. Is that possible without re-IP’ing every host?

Solution. No, not really. To create four /26s from a /24, every host whose existing address now lands in the wrong subnet has to be re-addressed (or the routers need to be configured very carefully with multi-net interfaces, which is an unusual setup). For example, a host at 192.168.0.130 was previously in the same broadcast domain as one at .50; in a /26 split they’d be on .128/26 and .0/26 respectively, with a router in between.

Answer: Subdividing existing IP space requires renumbering. Plan migrations with the new addressing first, deploy a router between segments, and migrate hosts in waves with DHCP doing the heavy lifting where you can.

Problem 20

You’re given 10.0.0.0/22 for a new branch. You need eight equal-sized subnets. What prefix do they get and what are the network IDs?

Solution. A /22 has 2^10 = 1,024 addresses. Eight equal subnets means each gets 128 addresses. 2^7 = 128, so each is a /25. Magic for /25 = 128. But because we span an octet boundary in the parent, we step in the 3rd octet by halves and the 4th octet by 128.

The eight /25s:

# Subnet Range
1 10.0.0.0/25 10.0.0.0 - 10.0.0.127
2 10.0.0.128/25 10.0.0.128 - 10.0.0.255
3 10.0.1.0/25 10.0.1.0 - 10.0.1.127
4 10.0.1.128/25 10.0.1.128 - 10.0.1.255
5 10.0.2.0/25 10.0.2.0 - 10.0.2.127
6 10.0.2.128/25 10.0.2.128 - 10.0.2.255
7 10.0.3.0/25 10.0.3.0 - 10.0.3.127
8 10.0.3.128/25 10.0.3.128 - 10.0.3.255

(The parent /22 ends at 10.0.3.255 — the last address of subnet 8 lines up exactly.)

Tier 5: real-world planning (problems 21–25)

The end of the practice ladder. These are the kind of problems you’ll be solving on actual jobs, and the answers depend partly on judgment.

Problem 21

You need to support a campus with three buildings. Each building needs to fit ~200 hosts on a single subnet. What prefix do you use per building, and what would you ask for from your IP team?

Solution. 200 hosts requires a prefix where 2^(host bits) − 2 ≥ 200. /24 gives 254 usable, just barely enough; if any building grows, you’re stuck. Better: /23 (510 usable). Then ask for an aggregable parent that holds three of them — a /21 contains four /23s, which gives you headroom for one more building.

Answer: Allocate a /21 from the IP team. Carve into four /23s; assign three to buildings A/B/C, hold the fourth in reserve.

Problem 22

Office of 35 people, expected to grow to 50 in a year. What size subnet?

Solution. Plan for 50, not 35 — renumbering after the fact is annoying. /26 (62 usable) covers 50 with margin. /25 (126 usable) is overkill but cheap if you have space. /27 (30 usable) is too tight even for today.

Answer: /26.

Problem 23

You’re given 10.0.0.0/16 for a new region. You expect to deploy 8–10 sites, each a campus network with mixed sizes. What’s a sensible per-site allocation?

Solution. /16 contains 64,000 addresses; with 10 sites, that’s ~6,000 addresses each. A /19 (8,192 addresses) is the right size: enough for a campus, multiple of which fit cleanly into the parent, and aggregable.

Answer: Allocate one /19 per site. With 10 sites you’ll use 10 of the 8 /19s in the /16 — oh wait, that’s only 8 sites. If you might exceed 8, ask for /15 instead, or allocate /20 per site (4,096 addresses each, 16 sites in a /16). The trade-off is per-site capacity vs total site count. Either is defensible.

Problem 24

You’re using 192.168.1.0/24 for the office and you want to peer it with another office that also uses 192.168.1.0/24. Can you?

Solution. No, not without re-numbering one of them. Routing depends on unique prefixes; two networks claiming the same address range can’t coexist on the same routed topology. NAT can hide one behind a different range, but that’s a workaround, not a fix — and it breaks return traffic for anything that includes the original IP in the payload (some VoIP, some DB protocols, etc.).

Answer: Renumber one of the offices to a non-overlapping range (often 10.X.0.0/16 or 172.16.X.0/24) before attempting to peer. Always pick non-default private ranges for any network you might want to merge later.

Problem 25

You inherit a network with subnets 10.0.0.0/24, 10.0.1.0/24, 10.0.2.0/24, 10.0.3.0/24. The router has separate routes to each. Could the routes be aggregated? Into what?

Solution. Four contiguous /24s starting on a 4-aligned boundary aggregate to a single /22. 10.0.0.0/24 through 10.0.3.0/24 = 4 × 256 = 1,024 addresses = a /22. The aggregate range is 10.0.0.0 - 10.0.3.255.

Answer: Yes, into 10.0.0.0/22. Aggregating reduces the size of the routing table and the work the router does on each packet — the same idea CIDR was invented for in 1993.

Speed-run quick reference

By problem 25 these should feel automatic. If they do, here’s the one-page reference for the rest of your career:

If you see… The fast move is…
Address with /N Mask → magic → round down → network ID
“Is X usable?” Compute network and broadcast; X is usable iff strictly between them
“How many hosts in /N?” 2^(32−N) − 2
“What prefix for X hosts?” Round X+2 up to next power of 2; that exponent is the host bits; prefix = 32 − host bits
VLSM — carve a parent Sort needs largest to smallest; allocate top-down with no gaps
“Are these two on the same subnet?” Compute network for each with the given mask; equal → same subnet
“Aggregate these prefixes” Find the smallest parent prefix that contains all of them on a clean boundary

What you can now do

  • Compute network ID, broadcast, first / last usable host, and next subnet for any IPv4 address with any prefix — including across octet boundaries.
  • Plan a VLSM split for a parent block, sized to host requirements with deliberate growth headroom.
  • Aggregate contiguous prefixes back to a parent for routing-table efficiency.
  • Recognise when two networks can’t coexist (overlap), can’t aggregate (not contiguous on a clean boundary), or shouldn’t be subdivided in place (renumbering pain).

What’s next

Subnetting is one of the gates between “reads about networking” and “does networking,” and you’ve cleared it. The next deep-dive article extends the addressing story to the protocol you’ll meet more and more in production: IPv6 deep dive — link-local addresses, SLAAC, multicast, neighbour discovery, and why the “just like IPv4 with more digits” mental model breaks down quickly.

Leave a Reply