Course outline · 0% complete

0/30 lessons0%

Course overview →

Subnetting a block, step by step

lesson 4-3 · ~14 min · 11/30

The question every subnetting problem asks

You are handed one block and a requirement, and you must produce a plan. The requirement comes in one of two shapes:

- "Split this block into n subnets." Borrow enough bits that 2 to the power of borrowed bits is at least n. - "Each subnet needs h hosts." Leave enough host bits that 2 to the power of host bits minus 2 is at least h.

Both shapes are solved with the same three numbers: how many bits you borrow, what the new prefix is, and what the block size is. Block size is the number of addresses per subnet, and it is also the step between consecutive subnet addresses, which is what makes it so useful.

borrowed bits b   -> 2^b subnets
new prefix        -> old prefix + b
block size        -> 2^(32 - new prefix)
usable per subnet -> block size - 2

Nothing else is needed. The rest is careful writing.

Worked example one: split a /24 into four subnets

Given 192.168.10.0/24. Wanted four equal subnets.

Step 1, how many bits to borrow. 2¹ = 2, too few. 2² = 4, exactly enough. So b = 2.

Step 2, the new prefix. 24 + 2 = /26. Mask 255.255.255.192.

Step 3, block size. 2^(32 − 26) = 2⁶ = 64 addresses per subnet. Or use the shortcut, 256 − 192 = 64.

Step 4, write the subnet addresses by stepping in blocks of 64, starting at the original network address: 0, 64, 128, 192.

Now write out the binary so the borrowing is visible. Only the last octet changes, and the two borrowed bits are the ones after the 24 bit line.

subnet 1  00 000000  =   0   -> 192.168.10.0/26
subnet 2  01 000000  =  64   -> 192.168.10.64/26
subnet 3  10 000000  = 128   -> 192.168.10.128/26
subnet 4  11 000000  = 192   -> 192.168.10.192/26
          ^^ borrowed bits count 00, 01, 10, 11

Step 5, fill in the boundaries. In each subnet the broadcast is the next subnet's address minus one, and the usable range is everything between.

SubnetNetworkFirst hostLast hostBroadcastUsable
1192.168.10.0192.168.10.1192.168.10.62192.168.10.6362
2192.168.10.64192.168.10.65192.168.10.126192.168.10.12762
3192.168.10.128192.168.10.129192.168.10.190192.168.10.19162
4192.168.10.192192.168.10.193192.168.10.254192.168.10.25562

Step 6, check the total. 4 × 64 = 256, which is exactly the /24. Nothing is lost and nothing overlaps. If your subnets do not add back up to the original block, you made an arithmetic error, so always do this check.

Note that 192.168.10.63 is no longer a usable host address even though it looks ordinary. Split a block and you create new broadcast addresses inside it. That is the single most common source of "this one address does not work" tickets.

192.168.10.0/24 · 256 addresses.0/26.64/26.128/26.192/260 to 6364 to 127128 to 191192 to 255hosts 1-62hosts 65-126hosts 129-190hosts 193-254block size 64, so subnets start at 0, 64, 128, 192
Splitting 192.168.10.0/24 into four /26s. Each subnet is 64 addresses wide and loses its first and last address to the network and broadcast.

Worked example two: a bigger block, and finding a host's subnet

Given 172.16.0.0/16, split into /24s. Borrowed bits: 24 − 16 = 8, so 2⁸ = 256 subnets, each with 2⁸ − 2 = 254 usable hosts. The subnets are 172.16.0.0/24, 172.16.1.0/24, and so on up to 172.16.255.0/24. Here the third octet is the subnet counter, which is why /24s inside a /16 are so pleasant to work with.

Now the reverse question, which is the one that appears in interviews: which subnet contains 172.16.37.200/24?

address  172.16.37.200   ... 00100101 11001000
mask     255.255.255.0   ... 11111111 00000000
AND      172.16.37.0     ... 00100101 00000000

Network 172.16.37.0, broadcast 172.16.37.255, usable 172.16.37.1 to 172.16.37.254. Our host sits comfortably inside.

Harder version, where the prefix does not land on an octet boundary. Which subnet contains 10.1.200.75/21?

Step 1, the mask. /21 is 8 + 8 + 5 ones, so 255.255.248.0. The interesting octet is the third one.

Step 2, block size. 256 − 248 = 8, so /21 subnets step through the third octet as 0, 8, 16, 24, and so on.

Step 3, which multiple of 8 is at or below 200? 200 ÷ 8 = 25 exactly, so 200 itself is a subnet boundary. Confirm in binary:

  11001000   (200)
& 11111000   (248)
  --------
  11001000   = 200, so the network is 10.1.200.0/21

Step 4, the broadcast is the last address of the block, so the third octet goes to 200 + 8 − 1 = 207 and the fourth octet fills with 1s.

network    10.1.200.0/21
first host 10.1.200.1
last host  10.1.207.254
broadcast  10.1.207.255
usable     2^11 - 2 = 2,046

Notice the subnet spans eight third octets, from 200 to 207. Prefixes shorter than /24 always do this, and forgetting it is why people wrongly think 10.1.203.5 is on a different network than 10.1.200.75. AND both with the mask and they are identical.

Requirement driven sizing, and a self check

Given 192.168.4.0/24, and every subnet must hold at least 100 hosts. What prefix?

Work the host bits upward. 2⁶ − 2 = 62, not enough. 2⁷ − 2 = 126, enough. So 7 host bits, prefix = 32 − 7 = /25, and the /24 splits into exactly two subnets, 192.168.4.0/25 and 192.168.4.128/25.

There is real tension here. 126 usable for 100 needed leaves only 26 spare. If that department grows past 126 you must renumber. Common practice is to leave roughly 30 percent headroom, so if a /25 is barely enough, ask whether the block you were given is the right size in the first place.

Three checks to run on any subnet plan before you trust it:

1. Alignment. Every subnet address must be a multiple of its own block size. 192.168.10.32/26 is not a legal /26 network, because 32 is not a multiple of 64. This is the most common mistake by far. 2. No overlap. Sort the subnets by address and confirm each one starts immediately after the previous one's broadcast. 3. Sum. Total addresses allocated must not exceed the parent block.

Try these on paper before moving on. Split 192.168.1.0/24 into eight subnets and write the four boundary values for each, then split 10.0.0.0/16 so every subnet holds at least 500 hosts. The answers use the same six steps every time, and after five or six repetitions the shortcut becomes automatic.