Layer 3 switch principle and configuration

Layer 3 switch principle and configuration

1. Overview of Layer 3 Switching Technology

  • Layer 3 switches use hardware to switch and route packets
  • Implement inter-VLAN communication using Layer 3 switching technology
  • Layer 3 switching = Layer 2 switching + Layer 3 forwarding

2. Traditional MLS

  • Layer 2 needs to be re-encapsulated during Layer 3 forwarding.

  • On a Layer 3 switch, the Layer 3 engine processes the first packet of the data flow.

  • The switching ASIC learns the Layer 2 rewrite information from the Layer 3 engine and creates an MLS entry in the hardware

  • Responsible for rewriting and forwarding subsequent data in the data flow.

    Simply put, after the host broadcasts the first ARP request, it sends the data to the Layer 3 switch. The switch learns the Layer 2 rewrite information from the Layer 3 engine, records it to the underlying hard disk, and forwards it. The next time it has the same request When the data flow of address information passes through again, forwarding is completed directly at the second layer (data link layer) according to this table, that is, "once routing, multiple exchanges", which effectively improves the efficiency of data packet forwarding. *Layer 2 must be re-encapsulated during Layer 3 forwarding.

3. MLS based on CEF

  • CEF concept: topology forwarding-based model
1. Forwarding Information Base (FIB)
2. Adjacency table

image-20231214154838574

3. Working principle:

① Host A sends a unicast data packet to host B

②. The switch searches the FIB table and finds the next hop address.

③. Find the Layer 2 encapsulation information of the adjacency relationship corresponding to the next hop address.

④、Forward

image-20231214154855066

4. Configuration of Layer 3 switch

1. Layer 3 switch configuration commands
SW1:

vlan batch 10 20 30: 建立vlan10 20 30

int g0/0/1: 进入接口模式

port link-type trunk: 选择端口类型(连接交换机)

port trunk allow-pass vlan all:允许所有vlan通过

int vlanif 10: 建立虚拟接口

ip add IP地址 子网掩码: 配置ip地址
SW2:

vlan batch 10 20 30: 建立vlan10 20 30

int e0/0/1: 进入接口模式

port link-type access: 选择端口类型(连接主机)

port default vlan 10: 将端口加入到vlan10中

int e0/0/4: 进入接口模式

port link-type trunk: 选择端口类型(连接交换机)

port trunk allow-pass vlan all:允许所有vlan通过
2. Layer 3 switch configuration steps
  • Create configuration and configure IP address on PC

image-20231214191313057

image-20231214191454481

image-20231214191602230

  • Configure switch SW2

image-20231214193855546

  • Configure switch SW1

image-20231214212525376

  • PC1 and PC2, PC1 and SW1 can all ping, and the configuration is successful.

image-20231214211753188

  • Layer 3 switches can do static routing, add routers and hosts, and configure them.

image-20231214223641283

  • Add configuration to SW1 and SW2

image-20231214221714300

image-20231214223206938

  • PC5, PC1, and PC2 can all ping, and the configuration is complete.

image-20231214223503752

Guess you like

Origin blog.csdn.net/2301_81272194/article/details/135006722
Recommended