Introduction
An IP address is assigned to a computer so that it can communicate in the network. An IPv4 address is 32 bits. The 32-bit address is subdivided into 4 octets. Each octet can hold a maximum of 255 integer values since each octet can hold 8 bits. In order to represent the block of IP address in the classless IP address, we make use of Classless Interdomain Routing(CIDR) notation. For example, w.x.y.z/n is used to represent the block of address in the classless IP address. Where 'n' is the length of network bits. Subnetting is the method of dividing the more extensive network into a smaller network which will be easy to maintain and secure.
Classless Subnetting
Before we jump into the subnetting first let us get to understand some of the basic concepts of the block of an entire network. Usually, the ISP provider will give you the block of an IP address as per your requirements. For example, if the ISP provider gives you 172.12.3.1/23 let's determine what information you can get from this block of IP address.
Since the length of the network bit is 23, you can determine the following things:
Network ID: It is the portion of the IP address that is used to identify the individual network.
Host ID: It is the portion of the IP address that uniquely identifies the computer in the network.
Host ID: It is the portion of the IP address that uniquely identifies the computer in the network.
Network Mask: It is used to separate the Network ID and Host ID.
Broadcast ID: It is the last IP address in the given block of IP address.
Total Number of IP addresses: 2^(32-n) where n is the length of the network bit.
Calculation
Now let's find out the Network ID, Network Mask, Broadcast ID, Range of the IP address(First Host ID and Last Host ID), and the total number of IP addresses from the above block of IP address.
Network ID
In order to find out the Network ID make all the host bits into zeros. The IPv4 address is made of 32 bits. Therefore the host bit is (32-n). In our example, the network bit length is 23. So the host bit is (32-23) 9 bits. Since the 9 bits represent the host bit so represent the 3 and 4 octets in binary. And turn the last 9 bits into 0 to find the Network ID.
Octet 1 | Octet 2 | Octet 3 | Octet 4 |
172 | 12 | 3 | 1 |
172 | 12 | OOOOOO11 | OOOOOOO1 |
Octet 1 and Octet 2 are 16 bits, still, seven bits are required, borrow 7 bits from Octet 3 and keep them as it because it represents the network bits(23). Reset others into 0. | |||
172 | 12 | OOOOOO1O | OOOOOOOO |
172 | 12 | 2 | 0 |
Therefore the Network ID: 172.12.2.0
Network Mask
To calculate the Network Mask, represent all the 23 network bits into 1 and the remaining host bit into zero. Then find its decimal equivalent.
Octet 1 | Octet 2 | Octet 3 | Octet 4 |
11111111 | 11111111 | 1111111O | OOOOOOOO |
255 | 255 | 254 | 0 |
Therefore the Network Mask: 255.255.254.0
Broadcast ID
In order to calculate the Broadcast ID, you have to turn all the host bits into ones. Then find its decimal equivalent.
Octet 1 | Octet 2 | Octet 3 | Octet 4 |
172 | 12 | 3 | 1 |
172 | 12 | OOOOOO11 | OOOOOOO1 |
172 | 12 | OOOOOO11 | 11111111 |
172 | 12 | 3 | 255 |
Therefore the Broadcast ID: 172.12.3.255
Total Number of IP Address
In order to find the total number of IP addresses, you can use the formula.
Total IP address: 2^(32-n) = 2^(32-23) = 2^9 = 512
Therefore there are 512 IP addresses available. But the usable IP address is 2 less than the total number of IP addresses because you can not use Network ID and Broadcast ID.
The usable IP address is 2^(32-n) - 2 = 512 - 2 = 510
Range of IP Address
The range of IP addresses represents all the possible usable IP addresses in the given IP address block. In the range given below it represents the first usable IP address to the last usable IP address.
First Usable IP Address | 172.12.2.1 |
…. | |
…. | |
…. | |
Last Usable IP Address | 172.12.3.254 |
Subnetting of 172.12.3.1/23 Classless IP Address
Now let's do the subnetting of the given block of IP address. For simplicity let's make the two subnets from the 172.12.3.1/23 block of IP address. In order to form the subnets, you have to borrow the bits from the host bits. If the subnets are in the power of 2 then you can make use of this formula.
2^N = Total Number of Subnets, N represents the borrow bits. In our case, the total number of the subnet is 2.
Therefore 2^N = 2, after solving the value of N, you will get N = 1. After borrowing the 1 bits from the host bits the network bit is (23 + 1) = 24.
Now let's determine the Network ID, Network Mask, Broadcast ID, Range of the IP address(First Host ID and Last Host ID), and the total number of IP addresses from the above block of IP address. The calculation method is the same that we have done above.
Subnet 1
Network ID: 172.12.2.0
Subnet Mask: 255.255.255.0
Broadcast ID: 172.12.2.255
Total Number of IP Address: 2^(32-24) = 2^8 = 256
Total Number of Usable IP address: 256 - 2 = 254
Range of IP Address: 172.12.2.1 --- 172.12.2.254
Subnet 2
Network ID: 172.12.3.0
Subnet Mask: 255.255.255.0
Broadcast ID: 172.12.3.255
Total Number of IP Address: 2^(32-24) = 2^8 = 256
Total Number of Usable IP address: 256 - 2 = 254
Range of IP Address: 172.12.3.1 --- 172.12.3.254
Tips: When you compute the subnet 1 address make the borrow bit as 0. In the case of subnet 2 make the borrow bit as 1.
Conclusion
In short, you have learned how to interpret the CIDR notation and do the subnetting of the classless IP address when the total number of subnets is the power of 2. Inside the subnetting, you have to know how to compute the Network ID, Subnet Mask, Broadcast ID, Total Number of IP Address, Total Number of Usable IP Address, and the Range of IP Address. If you have any doubt do leave a query in the comment box.