Each device connected to the network needs a unique IP address, but because the IPv4 version of IP addresses currently in use is not enough for current Internet users, IP addresses are divided into public IP addresses and private IP addresses, and NAT technology is used to alleviate the problem of insufficient IP addresses. In the IP address and subnet mask, we briefly talked about how to check the IP address in the WINDOWS system and talked about using the subnet mask to determine whether two IP addresses are in the same network segment to determine data forwarding. Private IP address range IP address is a hierarchical address represented by 32-bit binary, that is, 32 0s and 1s separated by periods, each 8 bits in a group, a total of four groups, but it is not easy to read a bunch of 0s and 1s, so we use the most commonly used decimal system to represent IP addresses. Since the largest decimal of 8-bit binary numbers is 2 to the eighth power, which is 256, the largest number in each group is 255 (starting from 0, 0 to 255 is exactly 256 numbers), so the maximum value of IP address is 255.255.255.255. Each group can have 256 IP addresses. For example, in the commonly used 192.168.1.*, the last * can take values from 0 to 255. The IP address is combined with the subnet mask to determine which are the network bits and which are the host bits. The same network number is in the same network segment or the same group, and the host bit determines how many hosts can be accommodated in the entire group. Murren Network Number The subnet mask is also four groups separated by dots, which is very similar to the IP address, but it has a clear feature that its 1s in binary are always continuous from the left, without exception. The 1s corresponding to the subnet mask in binary are network bits, and the 0s are host bits. For example, the default subnet mask of 192.168.1.1 is 255.255.255.0, which is converted into binary as 11111111.11111111.11111111.00000000. Based on the continuous 1s on the left side of the subnet mask, 255.0.0.255 is definitely not a correct subnet mask. The calculation method is to convert both the IP address and the subnet mask into binary, and then perform an AND operation. 1 and 1 equal 1, 0 and 0 equal 0, 1 and 0 or 0 and 1 equal 0. If the results are the same, they are in the same network segment, otherwise they are not. For example, are 192.168.1.1 and 192.168.1.200 the same group under the default subnet mask 255.255.255.0? 255.255.255.0 From the above figure, we can see that the calculation results are the same. The corresponding bit is 255.255.255, and the corresponding bit is the host bit. If we change the subnet mask, are 192.168.1.1 and 192.168.1.200 still in the same group? For example, the subnet mask is 255.255.255.128. Let's calculate in the above way, and we can see that the results are not the same. It can divide a large address block into small address blocks. This is the role of the subnet mask. The subnet mask can increase the number of 1s or decrease the number of 1s. So if you want 192.168.1.1 and 192.168.2.1 to be in the same network segment, you can reduce the number of binary 1s in the subnet mask, such as 255.255.0.0. You can calculate whether their results are the same. 255.255.255.128 The 192.168.1.0 calculated in the picture is the network segment number, which can also be understood as a group number or WeChat group, which has members. So how many members are there? Obviously, different subnet masks are different. For the default 255.255.255.0, it is 256, but for the changed 255.255.255.128, it is 128, because the maximum value is 256, minus 128 is 128. That is 128 members, two groups. They are 192.168.1.0 to 192.168.1.127 and 192.168.1.128 to 192.168.1.255. So the subnet mask of 255.255.255.192 is 256-192=64. There are 4 groups with 64 members in each group. 192.168.1.0 to 192.168.1.63, 192.168.1.64 to 192.168.1.127, 192.168.1.128 to 192.168.1.191, 192.168.1.192 to 192.168.1.255. IP and subnet mask You will find that IP addresses usually start from 1. In fact, in binary, all 0 host bits represent the network segment number, and all 1 host bits represent the broadcast number, so the first and last bits in a group will not be assigned to the host. If you write 192.168.1.0 and 255.255.255.0 to specify the IP address of the network card in the WINDOWS system, an error will be reported. Because its host bits are the last group of all 0s, the network segment number cannot be assigned to the host. Similarly, 192.168.1.255 subnet mask is 255.255.255.0 and cannot be assigned to the host because it is a broadcast number. Then can 192.168.1.128 and subnet mask 255.255.255.128 be assigned to the computer? IP address If they are members of the same group, they can communicate directly. If they are not members of the same group, a gateway is needed to forward the information to the outside. So when you want to access an IP address in the computer, it will first be calculated. If the result is consistent with all the IP addresses of the network card, it means that they are in the same network segment. It can be directly handed over to the switch to facilitate the communication through the second-layer MAC address. If they are different, it needs to be handed over to the gateway to continue forwarding to the outside. The gateway mentioned here is actually an IP address in the same network segment. The gateways of many home routers are the management addresses of the routers themselves. Those in the same group as the IP address obtained by the network card can communicate directly. In this way, the router will send the address that is not in the same network segment to the Internet through the WAN port. If the destination IP is in the same network segment, it will be sent to the corresponding LAN port instead of the WAN. |
>>: Introduction to the complete 5G system
[51CTO.com original article] This morning, Huawei...
On January 17, Huawei founder and CEO Ren Zhengfe...
Today, I will give you a long article about web a...
Kuroit is a foreign hosting company founded in 20...
The tribe began sharing about Yunding Network in ...
Number portability is an urgent need Number porta...
Structured cabling plays a vital role in network ...
Recently, the three major operators have successi...
DogYun has launched a promotion for Japanese data...
Mr. Dongguo and the wolf, Lu Dongbin and the dog,...
1. Introduction Software-defined wide area networ...
As the old saying goes, "It's hard to pr...
In the two years since 5G was put into commercial...
As we all know, the security of wireless routers ...
Hostwinds is a long-established foreign merchant ...