banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

This article explains what a three-layer switch, gateway, DNS, subnet mask, and MAC address are.

  1. What is VLAN?

  2. Single-arm routing and layer 3 switch

  3. What is a gateway?

    1. What is a gateway?
    2. How to understand a gateway?
    3. Gateway IP address
    4. How does a gateway enable communication?
    5. What is a default gateway?
  4. What is DNS?

  5. MAC address

  6. Subnet mask
    Many friends have repeatedly asked about what a gateway, DNS, subnet mask, and layer 3 switch are and their purposes. Indeed, because network technology is widely used in low-voltage electricity, we often discuss issues such as gateways, VLANs, layer 3 switches, or subnet masks in VIP technical groups. Today, let's understand them all at once in a popular way.

  7. What is VLAN?
    VLAN stands for "Virtual Local Area Network" in Chinese. LAN can be a network consisting of a few home computers or an enterprise network consisting of hundreds of computers. VLAN refers to a network divided by a router, which is the broadcast domain.

Based on the above concept, many friends must be confused about what a virtual local area network is and why VLANs need to be divided.

Here's an example to help you understand:

In a high school, 800 students were admitted in the new semester. If these 800 students are placed in one class, it would be difficult to manage. Facing 800 people, teachers would have a headache. Some students may not be able to hear the teaching, and some tasks may not be communicated properly. If a teacher wants to find information about a specific student, they would have to search through 800 pieces of information, which is extremely troublesome and time-consuming.

Similarly, in actual networks, when computer A wants to communicate with computer B, computer A needs to send an ARP request. In a network with many computers, the ARP request will be broadcasted to all computers in the same network in order to find computer B. As a result, finding computer B consumes the overall network bandwidth, and the computers receiving the broadcast information also consume CPU time to process it. This leads to a significant waste of network bandwidth and CPU processing power.

So, what can be done?

The school divided the 800 students into 10 classes, with 80 students in each class. Each class is named "Grade 1 (1)", "Grade 1 (2)", and so on, and each student is assigned a class number.

1101 represents student 01 in class 1.

1102 represents student 02 in class 1.

1201 represents student 01 in class 2.

Students in the same class have different numbers, but everything else is the same.

This is VLAN. Each class is equivalent to a VLAN, and each class name is equivalent to the VLAN's name. Each student's number is their IP address. Students in the same class (with the same VLAN IP) can communicate with each other because they are in the same classroom and spend time together. Students in different classes (different VLANs) may not be able to communicate with each other without additional configuration.

Therefore, communication is possible within the same VLAN, but not between different VLANs without configuration. How can different VLANs communicate? This requires single-arm routing and layer 3 switches.

  1. Single-arm routing and layer 3 switch
    To enable communication between different VLANs, routing functionality is required. There are two ways for communication between different VLANs (single-arm routing and layer 3 switch).

What is single-arm routing?

The implementation of single-arm routing is actually a combination of a regular layer 2 switch and a router, allowing communication between different VLANs.

640 (2)

So, what is a layer 3 switch?

For small networks, single-arm routing can suffice. However, as the traffic between VLANs increases, it may cause the router to become a bottleneck for the entire network, resulting in packet loss or communication congestion.

To solve this problem, layer 3 switches were introduced. A layer 3 switch is essentially a "layer 2 switch with routing functionality." Routing is a function of the network layer in the OSI reference model, so a switch with layer 3 routing functionality is called a "layer 3 switch."

For the internal structure of a layer 3 switch, refer to the simplified diagram below.

640

Within a single device, both the switch module and router module are set up. The built-in router module is the same as the switch module and uses ASIC hardware to handle routing. Therefore, compared to traditional routers, high-speed routing can be achieved. Additionally, the routing and switching modules are interconnected, ensuring a significant bandwidth due to the internal connection. Therefore, for formal projects, a layer 3 switch is required to achieve communication between networks.

  1. What is a gateway?
    After understanding VLANs and layer 3 switches, whether communication is possible depends on the correctness of the gateway.

  2. What is a gateway?
    A gateway, also known as an inter-network connector or protocol converter, is used to achieve network interconnection at the transport layer. It is the most complex network interconnection device and is only used to connect networks with different higher-level protocols.

  3. How to understand a gateway?
    As we all know, when moving from one room to another, we must pass through a door. Similarly, when sending information from one network to another, we must pass through a "gateway," which acts as a gateway to connect one network to another.

Depending on different classification criteria, there are many types of gateways. The most commonly used gateway in the TCP/IP protocol is what we refer to as a gateway.

  1. Gateway IP address
    So, what exactly is a gateway? Essentially, a gateway is an IP address that connects one network to another. It is selected from the available IP addresses within the network, but generally, the first and last IP addresses are used.

For example, let's consider Network A and Network B:
Network A: IP address range is "192.168.1.1~192.168.1.254" with a subnet mask of 255.255.255.0.

If communication with other networks is required, the gateway can be set as 192.168.1.1, or any other IP address within the network.

Network B: IP address range is "192.168.2.1~192.168.2.254" with a subnet mask of 255.255.255.0.

If communication with other networks is required, the gateway can be set as 192.168.2.1, or any other IP address within the network.

643

  1. How does a gateway enable communication?
    Without a router, TCP/IP communication between two different networks is not possible. Even if two networks are connected to the same switch (or hub), the TCP/IP protocol determines that hosts in different networks are in separate networks based on the subnet mask (255.255.255.0). To enable communication between these two networks, a gateway is required.

If a host in Network A finds that the destination host of a data packet is not in the local network, it forwards the data packet to its own gateway, which then forwards it to the gateway of Network B. The gateway of Network B then forwards it to a specific host in Network B (as shown in the diagram). This is the process of Network B forwarding data packets to Network A.

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

  1. What is a default gateway?
    If you understand what a gateway is, it is easier to understand what a default gateway is. Just like a room can have multiple doors, a host can have multiple gateways. The default gateway means that if a host cannot find a usable gateway, it sends the data packet to the default specified gateway for processing. Nowadays, the gateway used by hosts generally refers to the default gateway.

  2. What is DNS?
    DNS stands for Domain Name System, which is a server that translates domain names into IP addresses.

In simple terms, DNS translates domain names into IP addresses. Here's an example to help you understand:

When we enter "www.baidu.com" in a browser, the computer needs to communicate with the Baidu website. The machine needs to send packets outside, and the packets need to contain the IP address of the Baidu server. Since we don't know the IP address, the host asks the DNS server to automatically translate the domain name "www.baidu.com" into the IP address 61.135.169.105. Then, the IP address is written into the destination IP address field of the packet, enabling communication.

It's like writing a letter. You need to write the recipient's address so that the post office can send it to you. If you write the address in Chinese, the post office won't understand it, so you need someone to translate it into English. This is the role of DNS. Therefore, you need to set the DNS in your local connection to browse the web properly. Without setting DNS, you won't be able to access web pages.

  1. MAC address
    When talking about MAC addresses, it is necessary to mention IP addresses as well. Let's briefly explain IP addresses.

IP and MAC

Although IPv6 is now available, most of us still use the IPv4 protocol. The IP address is the identifier for your computer in the entire network. Other computers need this identifier to access your computer. However, this identifier often changes. The only thing that remains constant is your MAC address: the physical address.

MAC is a unique network address used to identify network card devices in a network. It is assigned by the relevant hardware manufacturers, and each computer has a unique MAC address.

To make an analogy, imagine you frequently move houses, and each time you move, you have a new address like "XX Community, Unit XX, Number XX." This is similar to an IP address. However, your name remains the same, which is like a MAC address. The difference is that MAC addresses cannot have duplicates.

644

Our IP address is divided into two parts: the network part and the host part. In the example above, it is divided into the network part and the host part. The network part is like being in a province, city, or town, which is determined by the country. However, the unit, building, and number are determined by the developer. The two parts combined form your IP address. The difference is that the lengths of the two parts are fixed in reality, but in the network, the IP addresses of A, B, C, and D can vary. This was explained in detail the day before yesterday.

  1. Subnet mask
    The subnet mask is used to distinguish between network bits and host bits. As mentioned earlier, an IP address consists of a network part and a host part. It's like a person's name consisting of a surname and a given name.

In this analogy, we can compare the IP address to a person's name, and the subnet mask to a list that quickly identifies people with the same surname and those with different surnames, grouping people with the same surname together so they can communicate with each other.

Here's an example:

Suppose there is a network range from 192.168.1.0 to 192.168.1.254, which is like a village called "Security Village." In this network range, there is an IP address 192.168.1.1, which we call "Security 1," and another IP address 192.168.1.2, which we call "Security 2." Just by looking at them, we know they belong to the same village.

There is another network range from 192.168.0.0 to 192.168.255.254, which we call "An Village." In this village, there are two IP addresses, 192.168.1.1 and 192.168.1.2, also called "Security 1" and "Security 2." Now, the question is, how do we differentiate whether they belong to Security Village or An Village?

This is where the subnet mask comes in to determine which network range they belong to. We need to take Security 1 and Security 2 to their respective villages to verify their identity and determine which village they belong to. The subnet mask for Security Village is 255.255.255.0, and for An Village, it is 255.255.0.0.

In a network, there may be IP addresses that are "homonyms" or "homographs." To distinguish which network range they belong to, we rely on the subnet mask.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.