Last time I wrote an article titled "In-depth explanation of MAC address table, ARP table, and routing table in 20 pictures", which mentioned the MAC address table. Each network card or layer three network port has a MAC address, which is burned to the hardware, so it is also cal

Preface

Last time I wrote an article "HTM420 pictures in-depth explanation of MAC address table , ARP table, routing table ", which mentioned MAC address table . So what is a MAC address table? What is the function of a MAC address table? What elements are included in the MAC address table? Today I will take you to have a good chat.

Let’s take a case as an example:

As shown in the figure above: PC1 and PC2 are directly connected through switch SW1, and PC1 wants to communicate with PC2 at this time.

1. According to TCP/IP reference model , if PC1 wants to communicate with PC2, in addition to knowing the IP address of PC2, it also needs to know the MAC address of PC2. We have already mentioned this in the previous chapter. You can obtain the destination IP address of PC2 through ARP broadcast. (The ARP table entry of PC1 is shown below)

2, PC1 encapsulates the packet and sends it to switch SW1. Switch SW1 will search for the MAC address table , match the MAC address of PC2, and find out that the interface is GE0/0/2. (The MAC address table of the switch is shown below)

3. Switch SW1 sends the message to PC2. After PC2 receives it, decapsulates finds that the destination MAC and destination IP are both their own, so they receive the message and continue processing.

or above is the communication process of the entire case, but have we ever thought about how the MAC address table of switch SW1 is generated? What is the MAC address table of the switch? What factors are composed of?

MAC address table

MAC address table: Simply put, the MAC address table is the mapping relationship between the switch and other network devices record the MAC address and port (see the figure below). It represents which port the switch learned a certain MAC address from. The switch records this information. When the switch needs to forward data, it can forward data according to the MAC address table according to the destination MAC address of the message.

On Huawei switch , you can use the command display mac-address to view all types of MAC address table entry information;

MAC address table function:

1. It is used to store the MAC address information of other devices learned by the switch.

2. When forwarding data, the switch queries the MAC table based on the destination MAC address and VLAN number in the Ethernet frame to quickly locate the outgoing interface of the device.

MAC address table mainly consists of: includes the destination MAC address, the VLAN to which the device belongs, the outgoing interface, the MAC table entry type, the aging time, etc.

Let’s talk about the five elements of the MAC address table respectively.

Destination MAC address

What is a MAC address?

Each network card or layer three network port has an MAC address . The MAC address is burned to the hardware, so it is also called hardware address . MAC address is the address identifier of the data link device. It is necessary to ensure that each MAC address in the network is unique in order to correctly identify the devices on the data link.

MAC address composition? The

MAC address consists of 6 bytes. The first 3 bytes represent the manufacturer identification code , and each network card manufacturer has a specific unique identification number. The last 3 bytes are allocated to each network card by the manufacturer. Manufacturers can ensure that the network cards produced will not have network cards with the same MAC address.

MAC address

MAC address representation method?

For the convenience of viewing, the 6-byte MAC address is represented by hexadecimal . The 8-bit binary numbers of each byte are represented by 2 hexadecimal numbers.

For example, my network card MAC address is 34-F6-4B-62-B3-85.You can use the command ipconfig /all to view how the switch learns MAC address by opening cmd on your PC?

1. When the switch receives a data frame from an interface, it will learn based on the source MAC address, and then add the mapping relationship between the MAC address and the interface to the MAC address table to generate the corresponding MAC address table entry

2. When the switch forwards the data frame, forwards based on the destination MAC address.

VLAN to which

When the interface on the switch has a bound VLAN, the generated MAC address table entry will identify the VLAN to which the interface belongs. In the figure below, the VLAN to which interface 10GE1/0/1 belongs is 100.

Regarding VLAN, let’s take a brief look at the concepts related to VLAN.

What is VLAN?

VLAN is a concept proposed to isolate the broadcast domain in layer 2.

For example, there are 15 people in our class. For the sake of convenience of management, we have 3 people and 1 group, divided into groups 1, group 2, group 3, group 4, and group 5. Then dividing VLANs is similar to the concept of packets.

is as shown in the figure below: We divide PC1 and PC3 into VLAN10, and PC2 and PC4 into VLAN20, so the same VLANs in can communicate, and the second layer between different VLANs cannot communicate. How to distinguish different VLANs from

?

is distinguished by VLAN ID. For example, VLAN 10 and VLAN 20 are different VLANs. What are the benefits of

VLAN technology?

increases the number of broadcast domains, reduces the size of each broadcast domain, , and also reduces the number of terminal devices in each broadcast domain;

enhances network security, and increases the method of ensuring network security;

improves the logic of network design, and can avoid the limitations of network design by geographic and physical factors.

VLAN Dividing

switches usually use the method of based on port division VLAN. Manually configure on the switch to bind the relationship between the switch port and VLAN ID.

The following figure shows the VLAN division based on the interface.

Advantages: Simple configuration. To divide a certain port into a VLAN, you only need to configure the port's PVID (port VLAN ID) to the corresponding VLAN ID.

Disadvantages: When the terminal device moves the location, it may be necessary to re-divid the VLAN for the new port connected to the terminal device.

In addition to this method, VLAN can be divided based on MAC address division VLAN , IP address division VLAN , , protocol division VLAN , , strategy division VLAN , strategy division VLAN ,

outbound interface

When the switch receives a data packet, it will look up the MAC address table based on the destination MAC address of the data frame. If it can match, it will send out the data frame based on the outbound interface of the table entry.

is shown in the figure above:

1, PC1 sends a data frame shown in the figure below to SW1, and the destination MAC is the MAC of PC2;

2, switch SW1 finds the MAC address table according to the destination MAC, matches the table entry, and forwards the data from port G0/0/2 according to the outgoing interface provided by the table entry;

3, PC2 decapsulates the data frame after receiving the data frame, and the communication ends.

MAC address table entry type

MAC address table generation methods, the most common one is dynamically generates MAC address table entry.

Let’s take a look at the table entry types of the MAC address table:

1, static: Static MAC address table entry. Manually configured by the user, the table entry will not be aged.

2, blackhole: Identifies the black hole MAC address table entry, which is manually configured by the user, and the table entry will not be aged.

3, dynamic: Identifies the dynamic MAC address table entry, which is obtained by the device through source MAC address learning. The table entry has an aging time and can be aged.

4, security: Identifies the secure dynamic MAC table entry, and the MAC address table entry learned after the port security function is enabled by the interface.

5, sticky: Identifies the Sticky MAC table entry, and the MAC address table entry learned after the Sticky MAC function is enabled by the interface.

6, mux: Identifies the MUX MAC table entry. When the interface enables the MUX VLAN function, the MAC address table entry learned by the interface will be recorded in the MAC address table entry of type mux.

7, snooping: The static MAC table entry type generated based on the DHCP Snooping binding table.

8, evn: Identifies the MAC address table entry that exists in the EVN or EVPN network.

9, authen: The MAC address entry formed by the user after passing MAC authentication or 802.1x authentication.

10, tunnel: The MAC address learned through the second-layer tunnel.

11, ovsdb: Identifies the MAC address table entry learned through OVSDB. The entries will not be aged by the VMware NSX controller to the local device. System reset or interface board hot-swap will not be lost.

Aging time

MAC Aging time: Dynamic MAC address learning time, unit is seconds.

Huawei switch can be used to view the aging time of dynamic MAC address entries in the MAC address table through the command display mac-address aging-time command.

Use this command to view the aging time of dynamic MAC address table entry is 0 seconds, indicating that the learned dynamic MAC address will not be transformed by old , which may cause the MAC address table entry to explode and reduce system performance.