IP Subnetting made easy – A subnetting tutorial

I’ve been asked to help people understand subetting and CIDR a few times.  In this post I give a short tutorial. Subnetting is explained in many places, with a large variety of methods. The key to working out valid subnets however is simply a matter of understanding the binary maths behind it.

This guide teaches you a simple method, suitable for the Cisco CCNA or ICND1 exam.

My Method

The method I use when subnetting starts with the table below. The first row shows the decreasing powers of 2, or to put it simpler – starting with 1 on the right, keep doubling the number 8 times, you should end up with 128. The row under it is easily calculated by adding up the numbers in the row above. For example, the 2nd cell from the left on the 2nd row (192), is calculated by adding 128 and 64 from the row above. The 3rd number (224) is 128+64+32, or to simplify, it’s the previously calculated 192, added to 32. This explanation might sound a little complicated, but that’s just because I wanted to be sure you understand the table below fully. The numbers in this table will become second nature to you after a little practice.

128 64 32 16 8 4 2 1
128 192 224 240 248 252 254 255

If you are using this method for a Cisco exam, I would suggest writing this table down as soon as you start the exam, as it will be a useful reference for any subnetting questions you get.

Example 1

The usage of the above chart is best explained by example, so I will start by talking though the following:

What is the broadcast address of the network

The number of interest here is the ‘254’ – which in the chart above is in the 7th column. Working out the CIDR notation for this is simple now; we know that the first 16 bits must be 1 (to give 255.255), and we simply add on the 7 found in our chart. This would give us a prefix of 16+7, which is 23.

In binary, this would mean that the subnet mask would look like:


The broadcast address in a subnet is the last address in the range, so to work though this question we need to figure out the valid subnets – this is where the chart comes in useful. The top number in the chart above ‘254’ is 2 – which is the increment to the network part of the address. This means the following are valid subnets:

As we can see above, the next network on from is, which means the broadcast address must be Additionally, we can see that we clearly have 510 assignable IP addresses – which is obvious from the above table, but can be worked out by doing (32 – 23)^2 – 2. To explain this calculation, if we have 23 bits (out of 32 – which is the length of a IPv4 address) identifying the network, we only have 9 bits left to identify a host. 9 bits gives us 512 unique addresses (9^2), but as each subnet needs a network address, and a broadcast address, we lose 2 addresses – so we have 510 usable addresses.

Example 2

What is the first valid host on the subnetwork that the node belongs to?

As a subnet mask is a 32 bit binary mask, a subnet mask length of 29, means we have 29 1’s, followed by 3 0’s. So here it is in binary:

We can see that the first 3 octets are 255, and therefore it’s only the last octet we are interested in. To find the matching row on the table above, we divide 29 by 8, and work with the remainder – which is 5. Looking at the chart, the 5th number along on the 2nd row is 248, so the subnet mask expressed in dotted notation is:

Above the number ‘248’ on the chart is the number 8, which means the network addresses go up in increments of 8:

We can see that the address must be part of the network, who’s first valid address would be


To quickly calculate valid subnets, you can again use the table above. In this example, we know the networks increment by 8 each time, but you might not know your 8 times table very well to quickly establish that is valid. Look at the table below, which is a modified version of the one at the top of the page.

128 64 32 16 8 4 2 1
128 192 224 240 248 252 254 255

It might not be obvious on your screen that the number ‘4’ in the top row is striked out!

All of the numbers above in bold that are not striked out are multiples of 8. The logic behind this is that all the numbers in the top row to the left of the number 8 are doubles of the number on the right, therefore everything must be divisible by 8. The bottom row, having been calculated by summing up the numbers on the top row, are also all multiples of 8 up until the 6th column. In the above example we are looking to see what subnet is part of, so we can quickly see from the modified table above that 128 is a multiple of 8 , and therefore a good starting point to figure out the subnet for, in this case we just need to minus 8 from 128, which gives us 120.

This might be a little confusing at first, but when understand it will help you solve some questions a lot quicker.

Final Example

Minimal text is used to explain the method in this example, to show just how simple it is.

What valid host range is the IP address a part of?

22 bits for for the subnet mask, 22/8 gives a remainder of 6. 6th column means subnet mask is Network increment is 4, nearest multiple of 4 to 36 is 36, next is 40. Range is –, first and last can’t be used, therefore valid host range is:


The method above might seem a little wordy and long winded, but that’s just because I’m trying to explain it as well as I can. However, mastering this method is simple. In order to help you practice, try this very useful site to generate questions.

34 thoughts on “IP Subnetting made easy – A subnetting tutorial”

  1. Great guide. I’m curious about your notation though. In Example 1, you write (32 – 23)^2 – 2, which reduces to 9^2, which you indicate reduces to 512. Shouldn’t that be 2^9 (which is 512) and 2^(32-23)?

  2. Well I think you have to have knowledge here anyway, cos as a person with no knowledge of subnetting ot whatever at all I didn’t get where you got half your numbers from.
    For instance,
    *As we can see above, the next network on from is, which means the broadcast address must be*
    Why must it be 151? You don’t explain where 151 comes from.

  3. thanks a lot now i now broadcast address is the last address of that network,second after adding is network address. chao

  4. THANK YOU!!! Subnetting has been a ‘skeleton in the closet’ for me for quite a while…your chart is awesome and finally made the light bulb go on. I appreciate your post.

  5. or to quote the text “(32-23)^2-2” is incorrect, it should be 2^(32-23)-2, the general formula being 2^X-2 = number of hosts

  6. I clueless on how to subnet in the 3rd octet i get the basic question but don’t have any clue as to the other octet PLZ HELP

  7. Hi, I still don’t get the “which means the broadcast address must be*” where does 151 come from.

    1. If you understand how the subnets were calculated then the subnet for extends from to the next subnet which is (but does not include

      So the IP addresses available in this subnet are from to

      Since the last IP address in a subnet is reserved for the broadcast address, the broadcast address for this subnet is

  8. Thank you very much, I Have no problem dowing Class C address, But Cass A & B I was lost,But Now I understand. Again Thank You. I can now finish My CCNA and move onto CCNP.

  9. i seem to struggle on these questions, the rest i got to a tea:

    How many subnets and hosts per subnet can you get from the network

    could you supply an explaination to help me with this type of question, thx.

  10. this will also help you…

    to find out how many subnets can be formed or created…
    Eg 1 :

    You need to figure out how many bits are for the subnet and how many are for hosts. If they give CIDR notation, it is easy: would have 9 borrowed bit for the subnet (Class B’s usually use 16 bits), so 2^n = 2 ^ 9 = 512 subnets. 7 bits are used for the host, so 2 ^ n – 2 = 2 ^ 7 – 2 = 128 – 2 = 126 hosts.

    One more example :

    How to find the total number of subnets available for one subnet mask.
    For example, take this subnet mask: and IP address as, ICND1 boook shows that there are 6 subnet for the given subnet mask, ranging from to , how 6 ? what to consider in ?

    The default mask for the class C address of 192.x.x.x is

    The mask in the example is (using 3 extra bits for subnetting, above and beyond the default).

    2^3 is 8 combinations:


    In the old days, we couldn’t use the all 000 or all 111 combination for subnetting, so the formula was 2^extra bits used for custom subnetting, or 2^3 in our example, -2 (for the 2 that used to not be able to be used), which would leave 6.

    Today, current IOS has the ability to use the 000 and 111 option with an option called subnet zero, and so on current IOS there would be 8 possible subnets, not just 6.

    The possible subnets would be
    the next subnet would jump by 32, to,
    and they would continue to increase by 32 until the subnet of was reached, for a total of 8 subnets

Leave a Reply

Your email address will not be published. Required fields are marked *