Home >Operation and Maintenance >Linux Operation and Maintenance >How does CIDR divide the network?
The first thing you need to know is what problem this CIDR is used to solve. We know that IP was initially divided into 5 categories, and we can only use the first three categories, but there are big problems with the division of these three categories. A Class B address can accommodate more than 60,000 hosts, while a Class C address can only accommodate more than 200 hosts. Such a classification will cause big problems. For example, if a company has thousands of people, then a Class C network will definitely not be able to meet the demand, but a Class B network will be too wasteful for it.
so what? IP classification has been eliminated and replaced by CIDR (Classless Addressing). The understanding of CIDR is also very simple. It uses a subnet mask to divide an IP into two parts. The first part is the network bit, and the latter part is the host bit.
Let’s take a look at what a subnet mask is. A subnet mask is the same as an IP address. It consists of 32 bits. It consists of consecutive 1s in the front and consecutive 0s in the back. We often use decimal notation to display the subnet mask. The following is a subnet mask:
255.255.255.0
The above subnet mask is composed of 24 consecutive 1s and 4 consecutive 0s. In addition, there is a common way of expressing subnet masks, which we call slash hair. As follows
192.168.110.121/24
The first part is the IP address, and the second 24 indicates the subnet mask. That is, it consists of 24 consecutive 1's and 8 consecutive 0's.
Matched with the subnet mask, there are several other knowledge points, such as calculating the network number, broadcast address, and the maximum number of hosts that the network can accommodate.
By ANDing the subnet mask with the IP address, you can get the network number
The last address of the network number is the broadcast Address
The number of available addresses is related to the number of host bits. For example, if the host bit occupies 8 bits, then the number of available addresses is equal to 2 to the 8th power minus 2 (one network address, one broadcast Address)
Next, we will use a case to consolidate the knowledge we have learned. As follows, the IP address and subnet mask, calculated network number and other information are given.
172.16.1.196/20
We know the following knowledge
1 & 1 = 1 0 & 1 = 0 1 & 0 = 0 0 & 0 = 0
Then this problem is simple. The first 16 digits must be unchanged, still 172.16, and the last 8 digits must be 0. Therefore, we only need to do the AND operation on the third part to get the answer.
The result of converting decimal 1 to binary is
00000001
Calculate 00000001&11110000, the obtained value is 00000000, and the converted value of 10 is 0. Therefore, the network number is
172.16.0.0
Next, calculate the number of available addresses. The host bit occupies 12 bits, so the available address is 2 raised to the 12th power minus 2, which is 4094.
The above is the detailed content of How does CIDR divide the network?. For more information, please follow other related articles on the PHP Chinese website!