The IP address can uniquely identify a host in the whole network, in fact, the IP address we usually see is actually composed of a network number and a host number. Suppose we want to find a student in the school through the student number, you can determine the student’s department major through the first half of the student number, and then determine the student’s class number according to the second half.
Network Number: Ensure that the two network segments connected to each other have different identities; hmi screen tft
Host number: Within the same network segment, the hosts have the same network number, but there must be different host numbers;
First, what is the network segment division
From the above example, it can be seen that the network number is equivalent to the department major, and the host number is equivalent to the class serial number. Network segment division is the division of the entire network into multiple zones, which we call “subnets”. Hosts in each subnet have the same network number, and host numbers that cannot be duplicated. The host number identifies the uniqueness within the network segment, just like in a major, there will be no two students in class 9 and number 3, but the class numbers of different majors can be the same.
2. How to allocate IP addresses in the subnet?
When a new host is added to a subnet, when assigning IP addresses, it is necessary to ensure that the host numbers are different, but manual allocation is too troublesome, in order to solve this problem, we proposed a technology called DHCP, which can automatically assign IP addresses to new host nodes in the subnet, avoiding the inconvenience of manual management.
Take our use of mobile phones to connect to WiFi as an example, we enter the Wifi password to verify legitimacy, in fact, in the access to a network segment of the router, when the authentication passes, at this time the router will be unused IP address to pick out a mobile phone assigned to you, as a temporary IP, the process of router assigning IP is the process of DHCP technology.
Supplement: We want to send a message to others, in fact, it is first passed to the router, and then passed by the router to other network segments; In addition, the router assigns a temporary IP address to the host that authenticates for communication.
Third, the classification of IP addresses
1. Early division
(1) Early classification
The earliest is to divide IP addresses into five categories. In order to draw a clear line between each class, the first bit or bits of each class are fixed.
Class A: 0.0.0.0 ~ 127.255.255.255
Class B: 126.96.36.199 ~ 188.8.131.52
Class C: 192.0.0.0 ~ 184.108.40.206
Class D: 220.127.116.11 ~ 18.104.22.168
Class E: 240.0.0.0 ~ 247.255.255.255
(2) Limitations of early classification
However, this division also has limitations, many organizations apply for Class B addresses, because the host number of Class B is 16 bits, and the number of hosts that can theoretically be accommodated in a subnet is 65536, which is relatively modest compared to Class A and Class C. This resulted in Class B addresses being applied for quickly.
In addition, there are actually no more than 60,000 hosts in a subnet, which leads to a large number of IP addresses in a subnet being wasted.
2. CIDR division (subnet mask division)
(1) Basic ideasTo reduce the number of ip addresses wasted in a subnet, we later introduced a subnet mask to distinguish between network numbers and host numbers. The main feature that distinguishes Class A and Class B is that the first few bits are fixed, not the number of bits of the network number and the host number, so how many bits are allocated by the network number and how many bits are allocated by the host number are determined by ourselves.
Taking Class B as an example, assuming that there are no actual 65536 hosts in a subnet, you can assign one bit of the host number to the network number, and one more bit of the network number is equivalent to adding two new subnets, which can be used elsewhere.
Still taking the above as an example, we want to divide the host number of the Class B IP address into a bit to the network number, in fact, we can divide the IP address and a 32-bit binary number “bitwise and”, the reserved part is the network number, and the number of hosts that can be in the network segment where the new network number is located is 32768. One of the binary numbers used is the “subnet mask”.
Compare the value ranges of the subnet IP addresses before and after:
<>. Limit on the number of IP addresses
IP address is a 32-bit positive integer, converted to decimal is about 4.3 billion or so, if each device is assigned an IP address, it is clear that the existing IP address is unable to meet the demand, although the subnet mask division to some extent alleviates the problem of insufficient IP address (improve utilization, reduce waste), but the problem of IP address depletion still exists.
Here are three other ways to alleviate the problem of insufficient IP addresses.
Dynamic IP address assignment: Assign only the IP address to the devices that access the network, and recycle the IP address after disconnection
IPv6: IPv6 is not a simple upgrade to IPv4. These are two protocols that are not related to each other and are not compatible with each other; IPv6 uses 16 bytes and 128 bits to represent an IP address, but IPv6 bit technology is not yet widespread.
<>. Private IP address and public IP address
If an enterprise internally wants to assemble a local area network for internal communication, but does not access the network, then the local area network can use any IP address. The key is not to access the network. RFC 1918 specifies private IP addresses for forming a local area network:
10.*, the first 8 digits are the network number, a total of 16777216 addresses
172.16.* through 172.31.*, the first 12 bits are the network number, a total of 1048576 addresses
192.168.*, the first 16 bits are the network number, a total of 65,536 addresses
All of the IP addresses in this range are private IP addresses, and the rest are called public IP addresses (global IP)