How to do Subnetting
Logical division of IP addresses inside network is subnetting or we can say, The process of giving host bits to network is subnetting. We already know that only a limited number of ipv4 addresses are available. We need to use these ipv4 addresses wisely and there are three ways for it.
- Private IPs
- SubnettingSo now we are going to learn What happens if we don’t do subnetting using example.
- 1 Prerequisites for subnetting in networking
- 2 What happens if we don’t do subnetting
- 3 Subnet Mask
- 4 Subnetting of an IP Address using examples
Prerequisites for subnetting in networking
- What is IP Address
- Convert IP Address from Decimal to Binary
- The “What is Subnetting” Article of Your Dreams
In case you are interested in CIDR you can check here.
What happens if we don’t do subnetting
So now we are going to learn What happens if we don’t do subnetting using example.
We want to assign two IPs 184.108.40.206 and 220.127.116.11 in two different sub-networks. We know that every interface of router must have a different network, which means every interface of router should have a different network ID. Now we can see in the above picture that we have given two different IPs to two different machines in two different networks. But there is a problem here. Both the IPs have same Network IDs.
It is not possible having the same network IDs in two different networks.
If we use the same network IDs for different router interfaces, router would not know in which network the traffic has to be send.
We can think of Network ID as a pin code and router as post office. If two cities have the same pin code, Post office would not know for which city the letter is to be dispatched.
We can give anything apart from 18.104.22.168 which can be like 22.214.171.124. Here we can see that Network IDs 126.96.36.199 and 188.8.131.52 belongs to two different networks, as a result these can be used in a big network.
Moreover by now if you are thinking that while creating subnets we cannot use the network IDs of the same class, you are wrong. We can use the same class network IDs in creating subnets until unless the network IDs are different.
We can create subnets using networks
184.108.40.206, which are Class C networks because both of these have different network IDs.
Before going further we need to understand what is Subnet Mask.
Network mask is a number which defines the range of IP Address which is being used in a network.
We call it a mask because it masks the network part of an IP Address and leaves the host part as it is.
|IP Address Class||Default Subnet Mask|
If there is only default Subnet Mask is given in CIDR, then there is no subnetting done.
From the above table we can conclude that if Subnet Mask of any IP address of class A is 8, then no subnetting has been done.
So if our CIDR is 10.0.0.0/8 then and there is no subnetting.
Subnetting of an IP Address using examples
Create subnet from CIDR 220.127.116.11/24 based on below diagram.
We can see that this is a class C IP address Subnet Mask is 24 which is default Subnet Mask for this class.
Get Network and Host parts
Convert Host part to binary
Calculate How many IPs can be given to biggest subnet (which have 40 machines) using below formula
2n -2 >=40
26 -2 >=40
According to this formula we can give 62 IPs in this subnet, though it is up us how many we want to assign.
Divide bits into Network and Host
Reserve n (6) bits to host and give remaining bits to network (Remember the Subnet definition in the beginning of the article?) which is 2
We know that the Subnet mask given is 24 which represent network. Now we will give these two bits to network and we will get our first subnet which is
Important thing to remember here is we represent host bits by 0 and Network bits by 1.
Formula: Catch the running ones
Divide the subnets further
- The second network would be
- Now add 64 again to last octet and we get:
- Fourth network would be:
- Next network would be
18.104.22.1686/26which is wrong as max no. in an octet can be 255
So with this CIDR we can create only 4 subnets in this particular network.
To create 5 subnets you would need to go for Class B CIDR