The Internet is everywhere and deeply affects our lives. The following knowledge is what we often encounter in online learning, but not everyone can easily express their concepts. IP address? Subnet mask? Gateway? We often confuse these knowledge, and they are easily asked during interviews. In simple terms: the IP address is used to mark the identity of your computer, just like each of us has an ID card; the subnet mask indicates which network segment the network used belongs to. Two IP addresses can communicate directly if they belong to the same network segment, but a gateway is needed when they belong to different network segments; and the gateway refers to the exit through which the sent information (data packets) go out, generally referring to the address of the router. Below we will introduce their differences and uses one by one. 1. IP address (1) What is IP protocol/address? That is, "a protocol that enables interconnection between networks", that is, the communication between computers over the network must follow the IP protocol. For example, if you are allowed to drive on the highway, then your vehicle must be licensed. If other people's vehicles are also licensed, then everyone can drive on the highway. Vehicles without licenses cannot drive on the highway. Here, the IP protocol is equivalent to the license plate that vehicles need to install. (2) Where is the IP protocol located? In the OSI (network seven-layer model), it is located in the "network layer". (3) What are the components of the IP protocol? It packages the data frames from the data link layer into the format of "IP data packets" and passes them to the next layer. (4) What is an IP address? IP address = grid number + host number. Classification of IP addresses (as shown below): Five types of IP addresses (5) Purpose of IP addresses The IP address is used to identify each computer. It assigns a logical address to each computer on the Internet, uniquely identifying the computer, which is the computer's network ID card. 2. Subnet mask (1) The meaning of subnet mask: What is a subnet mask? A subnet mask is used to determine whether the IP addresses of two computers belong to the same network segment. If two computers are in the same network segment, they can communicate directly. (2) Composition of subnet mask: It consists of 32 bits of binary, for example: Subnet mask binary: 11111111 . 11111111 . 11111111 . 00000000 is represented as: 255 .255 . 255 . 0 (3) Purpose of subnet mask: Masking part of the IP address is used to distinguish between the network identifier and the host identifier, so as to determine whether the IP address is on the local area network or the Internet. The entire huge IP network is divided into several small subnets. In addition, the computer's subnet mask can be used to determine whether two computers are in the same network segment. That is, convert the computer's IP address and subnet mask into binary, perform an AND operation, and if the results are the same, it means that the two computers are in the same network segment and can communicate directly. 3. Gateway (1) What is a gateway? For example, in ancient times, when we went from one place to another, we had to pass through a city gate. For example, when we went from the northeast to the inland, we had to pass through Shanhaiguan. This city gate was called a "gateway". In the same way, when we go from one network channel to another, we also have to go through such a "gateway", which we call a gateway here. It is the "entrance" from one network connection to another network. Popular understanding: Gateway: Usually refers to the default gateway. For example, if we use the subnet mask to determine that two computers are in different network fields, the two computers cannot communicate directly. In order to communicate, the gateway appears at this time, which can connect two computers in different network frequency bands together for communication. (2) What is the purpose of a gateway? For example, there are two networks, Network 1 and Network 2. If there is no router between the two networks, TCP/IP communication cannot be performed between Network 1 and Network 2. Because according to the above subnet mask, we can judge that Network 1 and Network 2 are in different networks, so in reality, in order for the two networks to be able to connect to each other, they must go through a gateway. Gateway is knowledge at the network layer. When two computers in different network fields want to communicate, they must go through the gateway. For example, you are communicating with an American, but you don't know English and the American doesn't know Chinese. What should you do? You can't communicate with each other. At this time, we can use a translator to translate the other person's words into a language that I can understand. That's it. The role of the gateway is the same. Two computers with different network frequency bands can communicate without obstacles through the gateway (the gateway needs a router to implement the protocol function). 4. Summary: The IP address is used to mark the identity of your computer, just like each of us has an ID card; the subnet mask indicates which network segment the computer uses. Two IP addresses belonging to the same network segment can communicate directly, but when they belong to different network segments, a gateway is needed to play a role; and the gateway refers to the connection between computers in different network segments, allowing them to communicate with each other. The gateway needs to rely on a router to complete its function. |
<<: Analysis | A Deeper Look at Apache Flink’s Network Stack
>>: Three pictures tell you the principles of Linux TCP/IP protocol stack
In recent years, the wave of digitalization has c...
Recently, more than 560,000 5G users in South Kor...
Friendhosting has released a new promotional offe...
Whether it is the turbulent forty years in Wu Xia...
Where will the data center of the future go? I be...
Single mode fiber Single-mode fiber has a thinner...
CMIVPS sent a promotional plan for this year'...
Aoyo Zhuji is one of the foreign hosting services...
Most discussions about technology transformation ...
Time flies, and the promotion of 5G has been goin...
[Shenzhen, China, July 24, 2020] At a press confe...
The coronavirus outbreak has had an unprecedented...
After HostDare launched the Los Angeles NVMe SSD ...
We had so much trouble getting security back to n...