subnetting is the process to take some bits from the host part and add them to the network part to create or define a sub network within a network. For example, we can take some bits to the next octet to make the address 184.108.40.206 which is different than the network 220.127.116.11.
As we know that in subnet mask bit 1 represents the network part and bit 0 represents the host part. This is the very basic calculation in case of subnetting. From the above examples we can see that these are Class A IP addresses. So we can simply find that our subnet mask is 255.0.0.0. Now if we convert that into binary then we find 11111111.00000000.00000000.00000000. So that, only first octet is the network part and the rest is host part.
If we take one more bit from the next octet then we can create a whole new network from this network. After that subnet mask will be 11111111.10000000.00000000.00000000. Now we can say that this network is different than the previous network. If we decimal the subnet mask then it will be 255.128.0.0. Using this subnet mask we can find how many hosts we can support.
Suppose we use 255.128.0.0 as our subnet mask and the IP address is 18.104.22.168. now here the first 9 bits are network part and the last 23 bits are host part. So let’s calculate how many hosts we can support using this subnetting.
The simple equation is
So our total available hosts will be: 223-2 = 8388606
Similar way we can define networks using subnetting and make smaller network like where only usable IPs will be just 2. If our subnet mask is 255.255.255.240 then we can find only 4 IPs to use where one IP will serve as network address and another IP will support as broadcast address. So we have only 2 IPs to use for host.
Similar way we can define subnetting using IPs which is called variable length subnet mask(VLSM). Using this method we do not change the subnet mask. Here we change the IP addresses. Like we have an IP 22.214.171.124/15 and 126.96.36.199/15, both of these IPs belongs to different networks. Let’s find how we calculate this subnetting.
Let’s convert the IPs into binary number
188.8.131.52 -> 00001011.00000000.00000000.00000000
184.108.40.206 -> 00001011.00000001.00000000.00000000
So in above we can see that only first 15 digits are similar in our binary form so out prefix will be 15. Now if we calculate the subnet mask then it will be
11111111.11111110.00000000.00000000 -> 255.254.0.0
So these are the subnetting methods in IPv4. We will discuss about some other networking technology in our next article.