IPv4 Subnetting By Hand

I wanted to do a dedicated section on IPv4 subnetting as this is typically the barrier to entry into computer networking. When I first started on this path of work, subnetting was the part I was dreading most. Even seasoned networking professionals (see Network Chuck) mention the leap from something relatively simple as the CompTIA A+ cert to subnetting in the Network+ or CCNA is significant. But with some practice, IPv4 subnetting can be easy.

I’m detailing this method as the CCNA requires being able to pick out networks in a subnet in a matter of seconds. It’s worth noting that this method does not require knowledge of the binary conversions, but you should be comfortable with binary conversions for the CCNA. Binary conversions, as well as network and host bits, are touched on in more detail in the IPv4 addressing section.

A lot of other methods require you to memorize a table and write that down, but that’s not as plausible in 2020, the year of virtual exams at home with no paper to write on. The method I will detail below requires that you only know the powers of 2, up to a power of 8:

2, 4, 8, 16, 32, 64, 128, 256

Let’s take a look at an example below:

10.0.0.0/24

A /24 network basically requires no additional knowledge other than each network will hold 254 hosts (remember we need to subtract two, one for the network address and one for the broadcast address in that network) So, subnetting a /24 network as above, for the first network we get:

10.0.0.0 – Network Address

10.0.0.1 – First Host

10.0.0.254 – Last Host

10.0.0.255 – Broadcast

10.0.1.0 – Next Network

If the next number in an octet ticks to 256, then the prior octet will go up by one, and the current octet will go to 0. Remember the highest an octet number will be is 255.

Let’s look at a /26 network:

192.168.1.1/26

This is where your knowledge of the powers of 2 is needed. Each octet is a multiple of 8:

8.16.24.32

So, if the CIDR notation of a subnet is /26, we’ll use the number in the fourth octet, 32, as 26 is higher than the prior octet of 24. We need to find the difference between 32 and 26, which is 6. This tells which power of 2 will be used to determine the number of hosts per network. 2^6 is 64. So the subnet of the example above is:

192.168.1.0 – Network Address

192.168.1.1 – First Host

192.168.1.62 – Last Host

192.168.1.63 – Broadcast

192.168.1.64 – Next Network Address

Let’s look at an example where the octet being changed by the subnet is not the 4th octet:

176.32.1.1/20

As shown above, because the CIDR notation is /20, this will change the number in the 3rd octet for the subnet, as it’s below 24. The method is no different though. We find the difference between 24 and 20, which is 4. This tells us our power of 2 to use, 2^4 = 16. What is different is how we display the subnet, the answer is below:

176.32.1.0 – Network Address

176.32.1.1 – First Host

176.32.15.254 – Last Host

176.32.15.255 – Broadcast

176.32.16.0 – Next Network address

Because the third octet is the one that changes, this means that a /20 network can hold significantly more hosts than a /26, as each number in the third octet between .1.1 and .15.254 can hold 255 hosts. Ex 176.32.14.132 is still in the same /20 subnet.

One last example:

176.32.1.1/13

Now, this CIDR notation subnet will change the second octet, as it is below 16. Same process, difference between 16 and 13 is 3, 2^3 = 8. So each network in the second octet is broken down by 8. Now, because the second octet isn’t a nice and easy 0 or 1, so we need to find out which network we’re working with in the subnet. We do this by taking the number in the second octet, 32, and dividing it by the power of 2 we’re using, 8. 32/8 = 4. So we’re in the 4th network in this subnet, and 176.32.0.0 is the network address for this subnet. If the number in the second octet were not a multiple of 8, we still divide, but round down (33/8 = 4.125, we would round it down to four, then multiply 8*4 = 32.) The closest multiple of 4 would be the beginning of that subnet:

176.32.0.0 – Network address

176.32.0.1 – First Host

176.39.255.254 – Last host

176.39.255.255 – Broadcast

176.40.0.0 – Next Network Address

The best way to learn this is to practice. Below is a link to a website (that I cannot take credit for) that will let you practice exactly these problems.

IPv4 subnetting practice: https://subnetipv4.com/

Converting CIDR notation to a subnet mask

What the above method does not detail is how to convert the CIDR notation into it’s proper subnet mask. A /24 CIDR notation is easy, 255.255.255.0. Again, the above subnetting method does not require any knowledge of the binary conversions, however, when determining the subnet mask, it does help to know the binary conversions. 255.255.255.255 in binary is written as:

11111111.11111111.11111111.11111111

Each binary one, from right to left, is 1, 2, 4, 8, 16, 32, 64, 128. The sum of all eight of those numbers equals 255. So, an octet of all binary 1’s is 255. The CIDR notation is the sum of the number of binary 1’s in each octet from left to right. Examples:

/8 CIDR is 255.0.0.0, which in binary is eight binary 1s: 11111111.00000000.00000000.00000000.

/16 CIDR is 255.255.0.0, which is binary is sixteen binary 1s: 11111111.11111111.00000000.0000000

/24 CIDR is 255.255.255.0, which in binary is twenty-four binary 1s: 11111111.11111111.1111111.00000000

So, let’s say we have a CIDR notation of /26. The subnet mask is 255.255.255.192. We can determine the subnet mask by knowing how many extra binary bits we are adding to the last octet, past the 24th binary bit:

11111111.11111111.11111111.11000000

We count them from left to right in this case. The extra two binary bits are 128 and 64. The sum of 128 + 64 = 192.

Wildcard Mask

You may get a question on the CCNA that will ask to find the wildcard mask of an IPv4 address and subnet mask. The wildcard mask is essentially the left over bits on the subnet mask. For instance, a subnet mask of 255.255.255.0 (which is a /24 CIDR notation), has a wildcard mask of 0.0.0.255. So, a question you may get on the CCNA is:

Find the wildcard mask of the following IPv4 address:

10.0.0.1 255.255.192.0

Because the wildcard mask is only the left over bits in the subnet mask, you would subtract 255 from each octet, and turn the negative numbers into a positive. The answer in this case is 0.0.63.255.

Conclusion

I hope this helps. Remember, practice makes perfect! The only way to be able to do this in your head in a matter of seconds is to practice, practice, practice. Good luck and happy testing!

One thought on “IPv4 Subnetting By Hand

Leave a Reply