This explains the relationship between IP address, subnet mask, and gateway, and even those without technical skills can understand it.

This explains the relationship between IP address, subnet mask, and gateway, and even those without technical skills can understand it.

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

Recommend

The computing power network has its own calculations

In recent years, the wave of digitalization has c...

2018 Top Ten Internet Trends Prediction: 5G Becomes the Focus

Whether it is the turbulent forty years in Wu Xia...

One cannot miss the key points of future data center development

Where will the data center of the future go? I be...

Teach you how to distinguish between single-mode and multi-mode optical fibers

Single mode fiber Single-mode fiber has a thinner...

Maxthon Hosting: 56 yuan/month Hong Kong CN2-2GB/40G SSD/300GB/15M Bandwidth

Aoyo Zhuji is one of the foreign hosting services...

Embracing the edge: Unleashing the potential of on-board computing

Most discussions about technology transformation ...

How to move your contact center to the cloud to prepare for the pandemic

The coronavirus outbreak has had an unprecedented...

HostDare adds NVMe disk CN2 GIA line VPS, 15% discount starting from $30/year

After HostDare launched the Los Angeles NVMe SSD ...

Enterprise IoT threatens to undermine cloud and IT security

We had so much trouble getting security back to n...

...