Skip to main content
IT BIBLESign in

Blog / Networking

Subnetting by Hand: The Block Size Method for Any Prefix Length

You can find the network, broadcast and usable range of any IPv4 address with one subtraction and a bit of counting. Here is the block size method, with worked examples and the usual mistakes.

RackGhostDwayne
· 5 min read · Networking
Subnetting by Hand: The Block Size Method for Any Prefix Length

Photo by Volkan Olmez on Unsplash

The problem: you are handed an address and a prefix, such as 192.168.10.77/26, and you need to know which network it sits in, where that network ends, and which addresses you can hand out. A subnet calculator will tell you. The trouble is that the calculator will also happily confirm a typo, and you will not notice. Learn to do it by hand once and you will catch the mistake in about ten seconds.

I use one method for every prefix length. It is called the block size method, and it needs one subtraction and some counting.

The idea

A subnet is a block of consecutive addresses. The size of the block is a power of two, and every block starts at a multiple of its own size. That is the whole trick. Think of a long row of mailboxes numbered from 0 to 255, bolted to the wall in groups. Each group has the same number of boxes, and a group always starts where the previous one ended. Your job is to find which group your address lives in.

The procedure

  1. Find the interesting octet. This is the octet where the mask is neither 255 nor 0. For /26 it is the fourth octet. For /20 it is the third.
  2. Write the mask value in that octet. Block size is 256 minus that value.
  3. List the multiples of the block size: 0, 64, 128, 192 for a block of 64.
  4. Find the largest multiple that is less than or equal to your address's value in that octet. That is the network address (octets to the left stay as they are, octets to the right are 0).
  5. The next multiple, minus 1, is the last address in the block. That is the broadcast address (octets to the right become 255).
  6. Usable hosts run from network plus 1 to broadcast minus 1.

If you do not have the mask values memorized, they are short. In the interesting octet, the values are 128, 192, 224, 240, 248, 252 for 1 through 6 mask bits in that octet. The block sizes are 128, 64, 32, 16, 8, 4. Learn that one line and you are most of the way there.

Example one: 192.168.10.77/26

A /26 is 255.255.255.192. The interesting octet is the fourth, and the value is 192. Block size is 256 - 192 = 64.

Multiples of 64: 0, 64, 128, 192. The number 77 sits between 64 and 128, so:

Network:    192.168.10.64
Broadcast:  192.168.10.127
Usable:     192.168.10.65 to 192.168.10.126
Hosts:      62

The host count is the block size minus 2, because the first address names the network and the last one is the broadcast. Forgetting that subtraction is the most common slip I see.

Example two: crossing an octet, 172.16.45.200/20

A /20 is 255.255.240.0. The interesting octet is now the third, with a value of 240. Block size is 256 - 240 = 16, and it counts in the third octet.

Multiples of 16: 0, 16, 32, 48. The third octet of our address is 45, which falls between 32 and 48. The fourth octet, 200, does not matter for finding the block.

Network:    172.16.32.0
Broadcast:  172.16.47.255
Usable:     172.16.32.1 to 172.16.47.254
Hosts:      4094

Notice that .0 and .255 in the fourth octet are perfectly ordinary host addresses here, as long as they are in the middle of the block. For instance 172.16.40.0 is a valid host in this subnet. People who learned subnetting only on /24 networks are often surprised by that. The only two reserved addresses are the first and the last of the whole block.

The host count: 12 host bits, 2 to the 12th is 4096, minus 2 is 4094.

Carving a block into smaller ones

The same method works in reverse when you are planning. Say you have 192.168.10.0/24 and want four equal subnets. Four subnets need 2 extra bits, so the prefix becomes /26, and the block size is 64:

192.168.10.0/26     hosts .1   to .62
192.168.10.64/26    hosts .65  to .126
192.168.10.128/26   hosts .129 to .190
192.168.10.192/26   hosts .193 to .254

Every start address is a multiple of 64, which is your sanity check. If you ever write down a /26 that starts at .50, something is wrong, because .50 is not a multiple of 64. A router will refuse it or, worse, quietly treat it as something other than what you meant.

For a home lab, this is also how I decide how big to make each VLAN. An IoT segment with thirty devices does not need a /24. A /26 gives 62 hosts and leaves room to grow, and the smaller broadcast domain is a small bonus.

Checking your answer in binary

When a result looks odd, check it in binary for just the interesting octet. Take 45 in the /20 example: 45 is 00101101. The mask in that octet is 240, which is 11110000. Keep the top four bits of the address and zero the rest: 00100000, which is 32. That matches the network address we found. The block size method is just this operation without the bit writing.

Common mistakes

  • Forgetting the minus 2 on host counts. A /30 has 4 addresses and 2 usable hosts, which is why it was the traditional choice for a point-to-point link. (Many modern devices also support /31 on point-to-point links, but check your equipment before you rely on it.)
  • Using the wrong octet. If the prefix is /20, the work happens in the third octet, and the block size is not 16 addresses, it is 16 third-octet values, or 4096 addresses.
  • Counting blocks from 1 instead of 0. The first block starts at 0.
  • Reading the broadcast as the next network's start. The broadcast is one less than the next multiple, not equal to it.
  • Trusting the calculator without a sanity check. If the network address is not a multiple of the block size, the answer is wrong.

Why bother

I have seen overlapping subnets cause an afternoon of strange routing, and the cause was a mask typed one bit off. When I plan a site-to-site link, such as two houses on 192.168.10.0/24 and 192.168.20.0/24, I want to prove by eye that nothing overlaps before I touch a config. Subnetting by hand lets you do that on the back of an envelope. It is boring, and boring is what I want from an address plan.

A next step: take 10.20.37.150/21 and work out the network, the broadcast, and the usable range on paper, without a calculator. Then check it with our calculator and see whether you agree.

https://itbible.org/tools/subnet-calculator

networkingsubnettingipv4
Share

Have a question about this guide?

Create a free account to ask the community and join the discussion. Members who run the real thing answer every day.

Sign in to comment.