Home > Subnetting Tutorial – Subnetting Made Easy

Subnetting Tutorial – Subnetting Made Easy

Calculate how many networks and hosts-per-subnet

In our example, you may raise a question: “when we borrow 8 bits, how many sub-networks and how many hosts per sub-network do it create?”

Note: From now, we will call sub-networks “subnets”. This term is very popular so you should be familiar with it.

How many new subnets?

Because we can change any bit in the second octet to create a new subnet, each bit can be “0” or “1” so with this subnet mask (255.255.0.0) we can create 28 more subnets. From here we can deduce the formula to calculate the newly created subnets. Suppose n is the number of bits we borrow:

The number of newly created subnets = 2n

In our example, we borrow 8 bits so we will have 2n = 28 = 256 subnets!

How many hosts per subnet?

The number of hosts per subnet is depended on the Host part, which is indicated by the “0” part of the subnet mask. So suppose k is the number of bits “0” in the subnet mask. The formula to calculate the number of hosts is 2k. But notice that with each subnet, there are two addresses we can’t assign for hosts because they are used for network address & broadcast address. Thus we must subtract the result to 2. Therefore the formula should be:

The number of hosts per subnet = 2k – 2

In our example, the number of bit “0” in the subnet mask 255.255.0.0 (in binary form) is 16 so we will have 2k – 2 = 216 – 2 = 65534 hosts-per-subnet!

Some other examples

Well, practice makes perfect so we should have some more exercises to be familiar with them. But remember that this is only the beginning in your journey to become a subnetting guru :)

Exercise 1

Your company has just been assigned the network 4.0.0.0. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.255.0?

(Please try to solve by yourself before reading the solution ^^)

Solution

First of all you have to specify which class this network belongs to. According to Table 1, it belongs to class A (simply, class A ranges from 1 to 126) and its default subnet mask is 255.0.0.0. Therefore if we use a subnet mask of 255.255.255.0, it means we borrowed 16 bits (to convert from 0 to 1).

255.0.0.0 = 1111 1111.0000 0000.0000 0000.0000 0000
255.255.255.0 = 1111 1111.1111 1111.1111 1111.0000 0000

Now use our above formulas to find the answers:

The number of newly created subnets = 216 = 65536 (with 16 is the borrowed bits)
The number of hosts per subnet = 28 – 2 = 254 (with 8 is the bit “0”s left in the 255.255.255.0 subnet mask)

Exercise 2

Your company has just been assigned the network 130.0.0.0. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.128.0?

(Please try to solve by yourself before reading the solution ^^)

Solution

130.0.0.0 belongs to class B with the default subnet mask of 255.255.0.0. But is the subnet mask of 255.255.128.0 strange? Ok, let’s write all subnet masks in binary:

255.255.128.0 = 1111 1111.1111 1111.1000 0000.0000 0000

This is a valid subnet because all bit “1”s and “0”s are successive. Comparing to the default subnet mask, we borrowed only 1 bit:

255.255.0.0 = 1111 1111.1111 1111.0000 0000.0000 0000

Therefore:

The number of newly created subnets = 21 = 2 (with 1 is the borrowed bits)
The number of hosts per subnet = 215 – 2 = 32766 (with 15 is the bit “0”s left in the 255.255.128.0 subnet mask)

Exercise 3

Your company has just been assigned the network 198.23.16.0/28. How many subnets and hosts-per-subnet you can create with a subnet mask of 255.255.255.252?

(Please try to solve by yourself before reading the solution ^^)

Solution

In this exercise, your company was given a “subnetted” network from the beginning and it is not using the default subnet mask. So we will compare two subnet masks above:

/28 = 1111 1111.1111 1111.1111 1111.1111 0000 (=255.255.255.240)
255.255.255.252 = 1111 1111.1111 1111.1111 1111.1111 1100 (= /30)

In this case we borrowed 2 bits. Therefore:

The number of newly created subnets = 22 = 4 (with 2 is the borrowed bits)
The number of hosts per subnet = 22 – 2 = 2 (with 2 is the bit “0”s left in the 255.255.255.252 subnet mask)

In this exercise I want to go a bit deeper into the subnets created. We learned there are 4 created subnets but what are they? To find out, we should write all things in binary:

Class_C_binary_form.jpg

Because two subnet masks (/28 & /30) only affect the 4th octet so we don’t care about the first three octets. In the 4th octet we are allowed to change 2 bits (in the green box) of the IP address to create a new subnet. So there are 4 values we can use: 00, 01, 10 & 11. After changing, we convert them back to decimal numbers. We get 4 subnets:

+ First subnet: 198.23.16.0/30 (the 4th octet is 00000000)
+ Second subnet: 198.23.16.4/30 (the 4th octet is 00000100)
+ Third subnet: 198.23.16.8/30 (the 4th octet is 00001000)
+ Fourth subnet: 198.23.16.12/30 (the 4th octet is 00001100)

So how about hosts per subnet? Please notice that all these 4 subnets are successive. So we can deduce the range of these subnets:

+ First subnet: ranges from 198.23.16.0 to 198.23.16.3
+ Second subnet: ranges from 198.23.16.4 to 198.23.16.7
+ Third subnet: ranges from 198.23.16.8 to 198.23.16.11
+ Fourth subnet: ranges from 198.23.16.12 to 198.23.16.15

Let’s analyze the first subnet which ranges from 198.23.16.0 to 198.23.16.3. Notice that all networks (and subnets) have a network address and a broadcast address. In this case, the network address is 198.23.16.0 and the broadcast address is 198.23.16.3 and they are not assignable or usable for hosts. This is the reason why we have to subtract 2 in the formula “The number of hosts per subnet = 2k – 2″. After eliminating these 2 addresses we have 2 addresses left (which are 198.23.16.1 & 198.23.16.2) as calculated above.

In the next part we will learn how to calculate subnet quickly. This is also a “must” requirement for CCNA so you have to grasp it.

Comments (8) Comments
  1. HOBBIT
    February 11th, 2020

    Hello help im new here my ip is 200.0.1.16/30 ?

  2. ali
    September 27th, 2020

    network class C 255.255.255.0 (/24) 192.0.0.0 – 223.255.255.255
    200.0.1.16/30
    255.255.255.252 = 1111 1111.1111 1111.1111 1111.1111 1100 (= /30)
    + First subnet: 200.0.1.16/30 (the 4th octet is 00000000)
    + Second subnet: 200.0.1.20/30 (the 4th octet is 00000100)
    + Third subnet: 200.0.1.24/30 (the 4th octet is 00001000)
    + Fourth subnet: 200.0.1.28/30 (the 4th octet is 00001100)

  3. Heathen Punk
    November 16th, 2020

    Hey Ali

    I think this is incorrect on your math:

    200.0.1.16
    255.255.255.252

    1st subnet = 200.0.1.0
    2nd subnet = 200.0.1.4
    3rd subnet = 200.0.1.8
    4th subnet = 200.0.1.12
    5th subnet = 200.0.1.16

    Don’t forget 0 (zero) is a number
    0 1 2 3 = 4
    4 5 6 7 = 4
    8 9 10 11 = 4
    12 13 14 15 = 4

  4. Seb
    May 7th, 2021

    hello, I did many exercice but one of them from CISCO is not understable for me
    You are implementing a VLSM network. You are using the Class B network of 172.16.0.0/16 and need to create 256 networks from this. The fifth network will then be subnetted into /30 networks.
    What is the subnet ID of the fourth /30 network?

    A. 172.16.4.12/30
    B. 172.16.4.4/30
    C. 172.16.4.6/30
    D. 172.16.4.8/30
    E. 172.16.4.14/30
    F. 172.16.4.10/30

    if we can give the solution and explanation it will be very helpful and useful

  5. Gatevisual
    May 9th, 2021

    Hello Seb

    The answer is A.

    Because if you VLSM 172.16.0.0 /16 and have 256 networks the fifth network will be 172.16.4.0 /24 and then if you subnet this with a /30 mask you’ll get this. 172.16.4.0 /30 network address

    172.16.4.1/30 first usable host address
    172.16.4.2/30 second usable host address
    172.16.4.3/30 broadcast address

    172.16.4.4/30 network address
    172.16.4.5/30 first usable host address
    172.16.4.6/30 second usable host address
    172.16.4.7/30 broadcast address

    172.16.4.8/30 network address
    172.16.4.9/30 first usable host address
    172.16.4.10/30 second usable host address
    172.16.4.11/30 broadcast address

    172.16.4.12/30 network address
    172.16.4.13/30 first usable host address
    172.16.4.14/30 second usable host address
    172.16.4.15/30 broadcast address
    and so on.

  6. bahath
    August 28th, 2022

    KINDLY SHARE THE WINDOWS SEVER TUTORIAL

  7. subn
    November 7th, 2023

    subnet mask in the example is inccorect. it should be 255.0.0.0 for 8 bit. your example was 255.255.0.0 and you gave 2 by the power of 8.

  8. kaz
    February 14th, 2024

    172.20.43.0/25
    how many subnets and what will be the each subnet first and last ip and network and broadcast ip?

Add a Comment