Subnetting Tutorial
Subnetting Tutorial
Subnetting Tutorial
In this article, we will learn how to subnet and make subnetting an easy task.
The table below summarizes the possible network numbers, the total number of each type, and
the number of hosts in each Class A, B, and C network.
Range
Class A
255.0.0.0 (/8)
1.0.0.0 126.255.255.255
Class B
255.255.0.0 (/16)
128.0.0.0 191.255.255.255
Class C
255.255.255.0 (/24)
192.0.0.0 223.255.255.255
Now you can clearly see that the subnet mask will decide which is the Network part, which is the
Host part. By borrowing 8 bits, our subnet mask will be like this:
After changing the second octet of the subnet mask from all 0 to all 1, the Network part is now
extended. Now we can create new networks by changing number in the first or second octet. This
greatly increases the number of networks we can create. With this new subnet mask, IP 11.1.0.1
is in different network from IP 11.0.0.1 because 1 in the second octet now belongs to the
Network part.
So, in conclusion we subnet by borrowing bit 0 in the Host portion and converting them to bit
1. The number of borrowed bits is depended on how many networks we need.
Note: A rule of borrowing bits is we can only borrow bit 0 from the left to the right without
skipping any bit 0. For example, you can borrow like this: 1111 1111. 1100 0000.0000
0000.0000 0000 but not this: 1111 1111. 1010 0000.0000 0000.0000 0000. In general, just
make sure all your bit 1s are successive on the left and all your bit 0s are successive on the
right.
In the next part we will learn how to calculate the number of sub-networks and hosts-per-subnet
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:
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:
Because two subnet masks (/28 & /30) only affect the 4th octet so we dont 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:
+
+
+
+
So how about hosts per subnet? Please notice that all these 4 subnets are successive. So we can
deduce the range of these subnets:
+
+
+
+
Lets 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 = 2 k 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.
In the previous examples, we have to write all subnet masks and IP addresses in binary numbers
to find out the results. It is a boring and time-consuming task. In this part I will show you a
shortcut to subnet without using a calculator or rough paper!
Subnetting The quick & easy way
One important thing we should notice is that a valid subnet mask must have all bit 1s and 0s
successive, in which bit 1s must be on the left; bit 0s must be on the right. Therefore we only
have 8 situations:
Table 3 How to find out increment based on the least-significant (rightmost) bit 1
Now lets solve Exercise 3 again by using this method:
Exercise 3 one again (with the decimal value of the rightmost bit 1 method):
Your company has just been assigned the network 198.23.16.0/28. How many subnets and hostsper-subnet you can create with a subnet mask of 255.255.255.252?
First use Table 2 to convert 252 to 1111 1100. The decimal value of the rightmost bit 1 is 4
(according to Table 3) -> The Increment is 4.
After finding out the increment we can deduce 4 subnets it creates.
The initial network 198.23.16.0/28 is also the first subnet, so:
+ The first subnet: 198.23.16.0/30
+ The second subnet: 198.23.16.4/30 because the increment is 4 so we plus the network address
with it to get the next network address (0 + 4 = 4)
+ The third subnet: 198.23.16.8/30 (4 + 4 = 8)
+ The fourth subnet: 198.23.16.12/30 (8 + 4 = 12)
Note: We should only choose one method to use and try to practice, practice & practice more with
it. Practice until you can solve any subnetting questions within 20 seconds!
Maybe you will ask why 256 can help you find the increment. In fact, by using the formula
Increment = 256 x you are trying to separate the rightmost bit 1 from other bits:
256 x = 255 x + 1
In which 255 x will convert all bit 0s to bit 1s and all bit 1s to 0s while +1 part will
make our result have only one bit 1 left. For example, if x = 240 then: