One article explains what is vlan, layer 3 switch, gateway, DNS, subnet mask, MAC address

Hello everyone, my network worker friend

The club's official account and network worker communication group have been established for so long, and friends keep asking in the background and in the group what is a gateway, dns, subnet mask... and the purpose of a layer 3 switch.

These are the foundations of the Internet. If you don't learn it solidly, there is really no way to advance.

In this article, I will give you a detailed and popular one-time explanation

Today's article reading benefits: "National Network Worker Exchange Group Entrance Quota (Limited Time Open)"

Mr. Yang’s network worker exchange group is about to break 100+. Do you want to chat about technology, industry, workplace or go to work in the group?

Private message me, send the password "Join the group", the top 20 friends who private message will be eligible to join the group.

01 What is a VLAN?

VLAN is "virtual local area network" in Chinese.

A LAN can be a network of a few home computers or an enterprise network of hundreds of computers.

The LAN referred to by VLAN refers to a network divided by a router—that is, a broadcast domain.

Listening to the above concepts, there must be many friends who are confused. What is a virtual local area network?

Well, why divide vlan?

Here is an example, to give you a simple explanation.

In a high school, 800 students were recruited in the first grade of the new semester. If these 800 students were placed in one class, they would definitely not be able to manage them.

Facing 800 people, the teacher felt a headache when he saw it. One side was teaching, but the other side couldn’t hear it at all. Whatever tasks the teacher assigned, some tasks would not be conveyed.

If the teacher wants to find the information of a certain student, he has to find it from 800 pieces of information, which is extremely troublesome and a waste of time.

And in reality, it is the same.

Computer A wants to communicate with computer B, so computer A needs to send an arp request, and there are many computers in the network, and eventually the ARP request will be forwarded to all computers in the same network to find computer B.

In this way, in order to find computer B, the overall bandwidth of the network is consumed, and the computer that receives the broadcast information also consumes part of the CPU time to process it.

It causes a lot of unnecessary consumption of network bandwidth and CPU computing power.

So what to do?

The school divided the 800 students into 10 classes.

There are 80 students in each class, which are respectively named Senior One (1), Senior One (2) ... Senior One (10), and everyone will get a class number.

1101 represents a class of 01 students.

1102 represents a class of 02 students.

1201 means student No. 01 in Class 2.

The student numbers in the same class have different endings, but the others are the same.

Then it will be much easier for the teacher to manage again, and the 80 people in a class can be properly managed

Class 2 and Class 3 next door are in a mess, and I don't care about the affairs of Class 1. I just want 80 people in this class to study well.

This is vlan, each class is equivalent to a vlan, and the name of each class is equivalent to the name of vlan.

And the number of each student is the ip address.

Classmates (IP of the same vlan), because they are in the same classroom, get along day and night, and can communicate with each other. If students in different classes do not do other work, it is difficult to communicate with each other.

Therefore, the same VLAN can communicate with each other; different VLANs cannot communicate with each other without configuration.

So how do different VLANs communicate? You need one-arm routing and a layer 3 switch .

02 One-arm routing and Layer 3 switch

We know that to achieve communication between different VLANs, there must be a routing function, and there are two ways to communicate between different VLANs (one-arm routing, three-layer switch).

01 What is one-arm routing?

The implementation of one-arm routing is actually an ordinary Layer 2 switch plus a router, so that different VLANs can communicate with each other.

02 So what is a Layer 3 switch?

For a small network, single-arm routing can handle it, but as the traffic between VLANs continues to increase, the router may become the bottleneck of the entire network, resulting in packet loss or communication congestion.

In order to solve the above problems, the three-layer switch came into being. A Layer 3 switch is essentially a "(Layer 2) switch with routing function".

Routing belongs to the function of the third layer network layer in the OSI reference model, so the switch with the third layer routing function is called "three-layer switch".

For the internal structure of the three-layer switch, you can refer to the following diagram.

In one body, a switch module and a router module are respectively set; and the built-in routing module is the same as the switching module, using ASIC hardware to process routing.

Therefore, high-speed routing can be achieved compared with conventional routers.

Moreover, the routing and switching modules are converged links, because they are internally connected, which can ensure a considerable bandwidth, so for regular projects, a layer-3 switch is required to realize communication between networks.

03 What is a gateway?

After understanding vlan and layer 3 switches, whether they can communicate or not depends on whether the gateway is correct.

01 What is a gateway

Gateway (Gateway) is also called Internet connector and protocol converter.

The gateway implements network interconnection on the transport layer and is the most complex network interconnection device, which is only used for the interconnection of two networks with different high-level protocols.

02 How to understand the gateway

Everyone knows that to walk from one room to another, one must pass through a door.

Similarly, sending information from one network to another must pass through a "gateway", which is a gateway.

As the name implies, a gateway is a "gateway" that connects one network to another.

According to different classification standards, there are many kinds of gateways.

The gateway in the TCP/IP protocol is the most commonly used, and the "gateway" we talk about here refers to the gateway under the TCP/IP protocol.

03 IP address of the gateway

So what exactly is a gateway?

The gateway is essentially the IP address of a network leading to other networks. The gateway selects one of the available IPs in the network segment, but the first and last ones are generally used.

for example.

For example, there are network A and network B:

Network A:

The range of IP addresses is "192.168.1.1~192.168.1.254", and the subnet mask is 255.255.255.0;

If it needs to communicate with other network segments, its gateway can be set to 192.168.1.1, of course, it can also be set to another ip address in the network segment.

Network B:

The IP address range is "192.168.2.1~192.168.2.254", and the subnet mask is 255.255.255.0.

If it needs to communicate with other network segments, its gateway can be set to 192.168.2.1, of course, it can also be set to another ip address in the network segment.

04 How does the gateway realize communication?

In the absence of a router, TCP/IP communication cannot be performed between two different networks.

Even if the two networks are connected to the same switch (or hub), the TCP/IP protocol will determine that the hosts in the two networks are in different networks according to the subnet mask (255.255.255.0).

And to realize the communication between these two networks, you must go through the gateway.

If the host in network A finds that the destination host of the data packet is not in the local network, it forwards the data packet to its own gateway;

Then the gateway forwards it to the gateway of network B, and the gateway of network B forwards it to a certain host of network B (as shown in the figure).

The process of forwarding data packets from network B to network A.

Therefore, only by setting the IP address of the gateway, the TCP/IP protocol can realize the mutual communication between different networks.

05 What is the default gateway?

If you figure out what a gateway is, the default gateway will be easy to understand.

Just like a room can have multiple doors, a host can have multiple gateways.

The default gateway means that if a host cannot find an available gateway, it will send the data packet to the default designated gateway, and the gateway will process the data packet.

The gateway currently used by the host generally refers to the default gateway.

04 What is DNS?

DNS is a domain name resolution server (Domain Name System), which is a server that converts a website into an IP address.

To put it bluntly, DNS is used to translate domain names into IP addresses. Here is an example, and it will be easy for everyone to understand.

For example:

When we enter http://www.baidu.com in the browser , the machine needs to communicate with the Baidu website.

The machine wants to send a data packet to the outside, and the IP address of Baidu's server must be written in the data packet. We don't know what the IP address is, so the host needs to ask the DNS server.

The DNS server automatically translates the domain name http://www.baidu.com into the IP address 61.135.169.105 for us.

Then write to the destination IP address of the data packet to communicate.

Just like we write a letter, you have to write the address of the recipient before the post office can send it to you.

When you write a letter to a foreign country, the post office does not know your address in Chinese, so you need someone to translate it into English for you.

This is the function of DNS, so you can browse the web normally only by writing DNS in the local connection. If you do not set DNS, you cannot access the web normally.

05 MAC address

When it comes to the MAC address, you have to mention the ip address. By the way, the ip address is also mentioned here.

01 IP and MAC

Although IPv6 is now available, most of the protocols we basically use are still IPv4.

By the way, I have heard that IPv4 will be charged next year.

You can take a look at this article: " Amazon: Next year, all public IPv4 addresses will be charged! ".

The so-called ip is the number of the entire network of your computer, and other computers need this number if they want to access the computer.

But this number is constantly changing in many cases. The only constant is your MAC address: the physical address.

MAC is the unique network address used to identify the network card device in the network.

Uniformly assigned by the relevant hardware manufacturer, the MAC address of each computer is unique.

To make a metaphor, you often move, and you have an address every time you move, XX unit XX in XX community, this is the IP.

But your name remains the same, this is the MAC, the difference is that our MAC does not allow duplicate names.

Our IP is divided into two parts: as shown in the figure above, it is divided into the network part and the host part.

The network part is like you are in XX Town, XX City, XX Province, which is fixed by the country.

But the number XX of unit XX in XX community is determined by the developer himself. The two numbers add up to your ip.

The difference is that in reality the lengths of the two numbers are fixed, but the IP addresses of A, B, C, and D on the network change. This was mentioned in detail the day before yesterday.

06 subnet mask

The subnet mask is to distinguish the network bit from the host bit. As we mentioned above, an ip address is composed of a network part and a host part.

Just as a person's name is composed of a first name and a last name.

Then we can compare the IP address to a person's name, then the subnet mask is like a list, we can quickly know those people with the same surname and those with different surnames, group people with the same surname into a group, and let them can communicate with each other.

To give you an example:

There is a network segment 192.168.1.0-192.1.254. This network segment is like a village, so it is called the Networker Village.

This network segment has an IP address of 192.168.1.1, we call him Network Worker 1, and another person is called Network Worker 2, whose IP address is 192.168.1.2, we can see that they are from the same village.

There is another network segment, which is 192.168.0.0-192.168.255.254. We call it a network village. There is also a network segment in the village with two IP addresses 92.168.1.1 and 192.168.1.2, also called network worker 1 and network worker 2.

So here comes the problem.

At this time, how to distinguish which village they belong to?

At this time, the subnet mask is needed to determine which network segment they belong to. You need to take the network worker 1 and the network worker 2 to the village to recognize them, and you will know that they belong to that village. The network segment of the network worker village It is 255.255.255.0, and the network segment of the net village is 255.255.0.0.

There will also be ip addresses similar to "same name" and "same surname" in the network. How to distinguish which network segment they belong to depends on the subnet mask.

Finishing: Lao Yang 丨 10-year senior network engineer, more network workers to improve dry goods, please pay attention to the official account: Network Engineer Club

Guess you like

Origin blog.csdn.net/SPOTO2021/article/details/132666405