Layer 3 switch working principle and configuration example

1. Layer 3 switch technology

  • Use layer 3 switch technology to realize communication between different vlans
  • Layer 3 switching = Layer 2 switching + Layer 3 forwarding

insert image description here

2. Layer 3 switch implementation

2.1 Traditional MLS

  • Route once, exchange many times
  • When using traditional MLS, the switch forwards the first data packet in the flow to the third layer engine, which processes the data packet in the way of software switching, and after routing the first packet in the data flow, The Layer 3 engine programs the hardware switching fabric to route subsequent packets. This process is called – one route and multiple exchanges, that is to say, the three-layer engine of the switch only needs to remove the first data packet in the data flow, and all subsequent data are forwarded by hardware. In this way, wire-speed forwarding of Layer 3 switching is realized.

2.2 CEF-based MLS

  • Different from traditional MLS, CEF learns the routing information in advance according to the routing table, and stores it directly in the FIB (Forwarding Information Base). The REF generates an adjacency table in advance according to the ARP table, which is directly forwarded by the hardware. Traditional MLS requires software to query the routing table at least once to create forwarding entries before using hardware for forwarding.
  • FIB (Forwarding Information Base)
  • adjacency table

2.3 Working principle

  • The third layer switching works in the third layer of the OSI seven-layer network model, that is, the network layer. It uses the header information of the IP packet in the third layer protocol to mark the subsequent data service flow, and the follow-up of the service flow with the same mark The message is switched to the second layer of the data link layer, thereby opening up a path between the source IP address and the destination IP address. This path goes through the second link layer. With this path, the three-layer switch does not need to unpack the received data packets to determine the route every time, but directly forwards the data packets and exchanges the data flow.
  • When a layer 3 data packet enters a layer 3 switch, it will check the routing table, that is, "primary route", find out the outgoing interface and the next hop, and then find the MAC address of the next hop, and perform the transformation of the layer 2 encapsulation, and the third layer The essence of layer devices, that is, routers, is the same (the essence of the three layers: it is to migrate the MAC of one subnet to another subnet, and the MAC of different subnets cannot appear on the source and destination MAC of the same packet. Some Layer 2 encapsulations are removed, and a new MAC address is encapsulated. The source is the MAC address of the outgoing interface, and the destination is the MAC address of the next hop. At this time, a new Layer 2 encapsulation is formed, and the data packet is forwarded to the device). router" work
  • If the MAC address of the next hop cannot be found, perform ARP flooding, and discard it if it is not found again. When doing layer 2 encapsulation, because of the existence of the target MAC, it can also be said that the target IP of the third layer will be mapped to the target MAC at the end. At this time, a mapping between the target IP and the encapsulated target MAC will be formed, and the three layers The switch has the function of a layer 2 switch, and a mapping from layer 3 to layer 2 is formed at this time. The forwarding must find the interface, find the MAC through the IP, and find the corresponding outgoing interface through the MAC, which is equivalent to forming an IP MAC table, then the corresponding outbound interface will be found directly after the three-layer IP comes in, and the data packet does not need to check the data table again, only need to change the two-layer encapsulation once.

4. Configuration example

1. Topological map, realize data communication between PC1 and PC2

insert image description here
2. PC configuration

insert image description here
insert image description here
3. Layer 3 switch configuration

insert image description here
4. Connectivity test; PC1: ping192.168.4.10

insert image description here

5. Summary

  • Layer 3 switch = Layer 2 switching + Layer 3 forwarding
  • Realize communication between different vlans
  • The main function of the router is to calculate the route, and the three-layer switch cannot
  • Layer 3 switches switch and route data packets through hardware. Simply speaking, Layer 3 switching is equivalent to Layer 2 switching plus Layer 3 forwarding.
  • The virtual interface of each vlan is the gateway of the network segment

Guess you like

Origin blog.csdn.net/fyb012811/article/details/131666323