An overview of the content of the article
In the previous article
- The IP address contains 32 bits and is usually divided into four 8-bits
- IP addresses are commonly expressed in dotted decimal notation (0~255.0~255.0~255.0~255).
- 32-bit IP addresses represent a total of 4.2 billion IP addresses, and without a reasonable way to allocate IP addresses, the whole allocation can be very troublesome. Therefore, you need to plan and allocate IP addresses properly
IP address of the class
Divide an IP address into two parts“The network number“and“The host“. These two pieces add up to 32 bits. According to the length of the network id and host ID, IP addresses can be classified into the following types:
By sorting them into A, B, and C, the 4.2 billion IP addresses will be better allocated
- The network number of A class A address is 8 digits, and the first digit is 0.
- The network number of a Class B address is 16 digits and the first two digits are 10.
- The network number of address C is 24 digits, and the first three digits are 110.
Knowing the number of network numbers and host numbers for each type of IP address, you can calculate the minimum network number, maximum network number, minimum host number and maximum host number. But there are some “special host numbers” that need to be excluded
Special host number
- Host numbers are all 0: indicates the current network segment and cannot be assigned to a specific host (for example, 1.0.0.0).
- Host numbers are all 1, indicating the broadcast address. Messages are sent to all hosts in the current network segment and cannot be assigned to a specific host (for example, 1.255.255.255).
Special network number
- Class A Address network segment 0(0000000) indicates A special network. This network segment cannot be used directly
- Class A Address The last seven bits of the network segment are all 1s (01111111), indicating the loopback address and cannot be used directly
- Class B address network segment all 0(10000000.000000:128.0) is unavailable
- Class C address network segments that are all 0(192.0.0) are not available
Once you know the special host number and the special network number, you can describe the above table more accurately
Through this you can easily determine what kind of IP address is the address
125.125.3.60 is 01111101 in base 2 because the first digit is 0, it is A class A IP address
163.70.31.23 is 10100011 in base 2, so it is a Class B IP address
When 210.36.127.11 is converted to base 2, it is 11010010. The first three digits are 110, so it is a Class C IP addressCopy the code
Loopback address
127.0.0.1, commonly known as a “Loopback Address,” does not belong to any of the categories of addresses. It represents the device’s local virtual interface, so by default it is considered an interface that will never break down. The Windows operating system has a similar definition, so you can usually ping the local loopback address before installing the network adapter. Generally, it is used to check whether the local network protocol and basic data interface are normal
In fact, there are two categories of IP address, class D and class E, because they are generally used for special purposes, so do not do specific understanding
Divide the subnet
A company has 100 employees, each equipped with a computer. Which network segment should the company apply for?
Take a look at the table above for IP address categories
It can be seen that applying for Class C is the most economical IP address, because class C has a maximum of 254 host numbers, so you should apply for class C
Assuming that the company has 256 employees, each equipped with a computer, which network segment should the company apply for? At this point, it is found that the application of class C address is not enough. Therefore, we should at least apply for a class B address to meet the company’s needs. But B can have at most 2 to the power of 16 minus 2 host numbers, and only 256 are used here, resulting in a “significant waste of address space.” Since there are 4.2 billion IP addresses, if every company were to waste them like this, there wouldn’t be enough IP. Therefore, on the basis of IP classification, the concept of subnet division is proposed
As mentioned earlier, an IP address consists of a network number and a host number. In subnet division, an IP address is divided into three parts: network ID, subnet ID, and host ID
How do subnet numbers work
Suppose that in the example above, class C address 193.10.10.0 is assigned and 254 host numbers are assigned to this class C address. If we subdivide this class C address, we can put“25th“As a subnet number (11000001.00001010.00001010.“0“0000000), which can be divided into two subnet numbers: 1 and 0. In this case, 0 indicates the network segment 193.10.10.0 to 193.10.10.127. 1 The subnet can represent the network segment 193.10.10.128 to 193.10.10.255. In this way, the original Class C address is divided into two subnets
If the IP addresses of class A, B, and C are divided into many subnets, there will be many subnets. In this case, how to quickly determine which network number an IP address belongs to? At this time, a new concept was proposed: “subnet mask”
Subnet mask
- The subnet mask and IP address are both 32 bits
- The subnet mask consists of consecutive 0s and consecutive 1s
- The subnet mask of a subnet that has “network number bits with consecutive 1’s”
For example, for A class A address, the network number has 8 bits and the host number has 24 bits. Then for A class A address, the subnet mask consists of 8 ones and 24 zeros, i.e“255.0.0.0“. Similarly, the subnet mask of a class B address is composed of 16 ones and 16 zeros, i.e“255.255.0.0“
Subnets of class C addresses are divided into 0 and 1. Then, the subnet mask of this subnet consists of 25 1s and 7 0s, and the subnet mask is 255.255.255.128 in dotted decimal notation
How is the subnet mask used for quick subnet judgment
Assuming that there is an IP address 193.10.10.6, its subnet mask can be known as 255.255.255.128 first, then their binary is represented, and each bit of them is calculated, and the following result will be obtained
As you can see, the calculated result is 193.10.10.0, which is the subnet number of the IP address
Suppose there is an IP address of 193.10.10.129, whose subnet mask is 255.255.255.128, then represent their binary and calculate each bit of them, and the following result will be obtained
As you can see, the calculated result is 193.10.10.128, which is the subnet number of the IP address
Therefore, “Through the and operation of the subnet mask and IP, the subnet number of the IP can be quickly obtained.”
Unclassified addressing CIDR
Because the subnets are divided or relatively complex, we should know the network number first, and then divide the subnet number. We wanted to have a better, easier partition to use IP addresses, so we came up with classless addressing CIDR.
- CIDR has no concept of class A, B, or C network numbers and subnets
- CIDR refers to an IP address with the same “network prefix” as a “CIDR address block”
Therefore, for CIDR, its IP address is divided into two parts: the “network prefix” and the “host number”. The network prefix is not the same as the preceding network number. The main difference is that “the number of the network prefix is arbitrary.”
Slash notation
CIDR usually uses slash notation to record associated IP addresses. For example, 192.10.10.129/25 indicates that its network prefix has 25 digits, so the host number is seven digits.“11000001.00001010.00001010.1“0000001). There’s a lot more than 25
A company has 100 employees, each with a computer. Which network segment should the company apply for? If CIDR is used for assignment, you simply assign it an IP network number with a network prefix of 25 (/25).
Suppose the company increases the number of employees by 100 and splits into two departments. How will IP planning be conducted? In this case, they can be assigned a 24-bit network prefix IP address, and then assigned a 25-bit network prefix IP address for each department. So there’s the notion of small networks and large networks, and in CIDR, small networks are often called“subnet“For the network prefix with 24 bits, in CIRDR, called“Super net“
If we expand this example to a particular city. If CIDR is used for network planning for a city, it is possible to assign a network address with the network prefix 18 to the city, a network address with the network prefix 20 to companies in the city, and a network address with the network prefix 24 to companies
It is the core competitiveness of a technician to seek invariance in the rapidly changing technology. Unity of knowledge and practice, theory and practice