当前位置:网站首页>Learning diary - (routing and switching technology) layer 3 switch
Learning diary - (routing and switching technology) layer 3 switch
2022-07-23 12:50:00 【Make money and marry sweet】
One 、 Related knowledge
1、 What is layer 3 Switching Technology ?
- Simply speaking , Layer 2 switching technology + Three layer forwarding technology . It solves the problem of network segment division in LAN , The situation that the subnet must be managed by the router , It also avoids the low speed of traditional routing 、 Network bottlenecks caused by complexity .
- A device with three-layer switching function is : A layer 2 switch with layer 3 routing function , But it is an organic combination of the two , It is not simply to superimpose the relevant hardware and software of the router on the layer-2 switch .
- principle : Suppose two uses IP The site of the agreement A、B Use IP Protocol to communicate ,A towards B Before sending data , First judge and B Is it the same subnet , If it is , Use layer 2 to forward , If not on the same subnet ,A Want to “ Default gateway ”( Default gateway IP The address is actually the switching module of the layer 3 switch ) send out ARP( Address resolution ) Packet
- advantage : Because only three layers are used in the routing process , The rest is forwarded through layer 2 , So the speed of layer 3 switch is very fast , It's similar to the second floor , And it's much cheaper than routers .
2、 The difference between layer 3 switch and layer 2 switch
- The main functions are different : On the second floor 、 Three layer switches can exchange and forward data frames , But there are also three-layer switches IP Routing functions
- Different places of use : The layer-2 switch is used for OSI The second layer of the model , Layer 3 switches are used in OSI The third layer of the model .
- The way data is processed is different : The layer 2 switch uses Layer 2 switching forwards data frames , Three layer switching routing module Use layer 3 switching IP Data packets .
3、 The difference between layer 3 switch and router
1、 Now the layer 3 switch can perform most of the functions of the traditional router
2、 The three-layer switch has the following characteristics :
- Forward the business flow based on the third layer
- Full exchange function
- Can complete special services , Such as message filtering or authentication
- Execute or not execute the routing function
3、 Switches are generally used for LAN-WAN The connection of , Switch belongs to bridge , Acting on the data link layer : Routers are generally used for WAN-WAN The connection of , It works on the network layer
4、 Routers are more powerful than switches , But the price is high , Relatively slow , The layer-3 switch has the ability to forward messages at line speed , It also has a good control function of the router .
Two 、 A simple example ( Three layer switch 、VLAN Routing between )
Three layer switch
1、 Simple topology

2、 Related codes
Three layer switch 1:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host R1
R1(config)#int
R1(config)#interface F
R1(config)#interface FastEthernet 0/1
R1(config-if)#no sw
R1(config-if)#no switchport ( After entering the interface , Change the layer-2 interface into the layer-3 interface )
R1(config-if)# The following two lines are tips
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config-if)#ip add
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
R1(config-if)#e
R1(config-if)#exit
R1(config)#interface FastEthernet 0/2
R1(config-if)#no sw
R1(config-if)#no switchport
R1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
R1(config-if)#ip add
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#e
R1(config-if)#exit
R1(config)#interface FastEthernet 0/3
R1(config-if)#no switchport
R1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
R1(config-if)#ip address 192.168.2.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#e
R1(config-if)#exit
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#show ip route In this section, the route is not opened after configuration , need ip routing Turn on the routing function
Default gateway is not set
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip routing ( Turn on the routing function )
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.12.2 ( Configure static routing )
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, FastEthernet0/2
C 192.168.2.0/24 is directly connected, FastEthernet0/3
S 192.168.3.0/24 [1/0] via 192.168.12.2
C 192.168.12.0/24 is directly connected, FastEthernet0/1
Three layer switch 2:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host
Switch(config)#hostname S2
S2(config)#int Fq
S2(config)#int F
S2(config)#int FastEthernet 0/1
S2(config-if)#no sw
S2(config-if)#no switchport
S2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
S2(config-if)#ip add
S2(config-if)#ip address 192.168.12.2 255.255.255.0
S2(config-if)#no sh
S2(config-if)#no shutdown
S2(config-if)#e
S2(config-if)#exit
S2(config)#int FastEthernet 0/2
S2(config-if)#no switchport
S2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
S2(config-if)#ip address 192.168.3.254 255.255.255.0
S2(config-if)#no shutdown
S2(config-if)#end
S2#
%SYS-5-CONFIG_I: Configured from console by console
S2#conf t
S2(config)#ip routing
S2(config)#end
S2#
%SYS-5-CONFIG_I: Configured from console by console
S2#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.3.0/24 is directly connected, FastEthernet0/2
C 192.168.12.0/24 is directly connected, FastEthernet0/1
S2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
S2(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1 Configure static routing
S2(config)#ip route 192.168.2.0 255.255.255.0 192.168.12.1
S2(config)#end
S2#show ip route
Configure the routing table after static routing
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.1.0/24 [1/0] via 192.168.12.1
S 192.168.2.0/24 [1/0] via 192.168.12.1
C 192.168.3.0/24 is directly connected, FastEthernet0/2
C 192.168.12.0/24 is directly connected, FastEthernet0/1
result : The result is that the layer 3 switch enables the routing function , All network segments can be interconnected . ( notes , After completing the configuration of the layer-3 switch, configure the static route )

Here are just ping PC3(192.168.2.1) and PC5(192.168.3.1), The layer 3 switch is finished .
Second example :VLAN Routing between
If you want to achieve VLAN Routing between , It needs to be divided into two steps
- First step ,VLAN Inter Division , Realize the functions of the second layer
- The second step ,VLAN Routing between
1、 Simple topology

2、 Related codes
S1( Three layer switch ):
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host
Switch(config)#hostname S1
This part is VLAN Division Arrange according to the topology , Divide into vlan10、20、30
S1(config)#vlan 10
S1(config-vlan)#exit
S1(config)#vlan 20
S1(config-vlan)#exit
S1(config)#vlan 30
S1(config-vlan)#exit
This part divides the corresponding interfaces into corresponding VLAN
S1(config)#int f
S1(config)#int fastEthernet 0/1
S1(config-if)#sw
S1(config-if)#switchport md
S1(config-if)#switchport mod
S1(config-if)#switchport mode ac
S1(config-if)#switchport mode access
S1(config-if)#sw
S1(config-if)#switchport ac
S1(config-if)#switchport access ?
vlan Set VLAN when interface is in access mode
S1(config-if)#switchport access vlan 10
S1(config-if)#e
S1(config-if)#exit
S1(config)#int fastEthernet 0/2
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20 These three commands are the key
S1(config-if)#e
S1(config-if)#exit
S1(config)#int fastEthernet 0/3
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 30
S1(config-if)#e
S1(config-if)#exit
S1(config)#%SPANTREE-2-RECV_PVID_ERR: Received 802.1Q BPDU on non trunk FastEthernet0/4 VLAN1.
%SPANTREE-2-BLOCK_PVID_LOCAL: Blocking FastEthernet0/4 on VLAN0001. Inconsistent port type.
S1(config)#
This is the configuration trunk mouth Be careful , The layer 3 switch cannot be configured trunk mouth , Must be configured on the layer-2 switch , Then the interface of the same link automatically becomes trunk Pattern .
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
The second step :vlan Routing between You only need to configure on the layer 3 switch , The second floor does not need .
S1(config)#interface v
S1(config)#interface vlan 10
S1(config-if)#
Prompt information ( The following two are also )
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
S1(config-if)#ip add
S1(config-if)#ip address 192.168.10.254 255.255.255.0 ( configure gateway )
S1(config-if)#no sh
S1(config-if)#no shutdown ( Can ignore not write )
S1(config-if)#e
S1(config-if)#exit
S1(config)#interface vlan 20
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
S1(config-if)#ip address 192.168.20.254 255.255.255.0( configure gateway )
S1(config-if)#no shutdown
S1(config-if)#
S1(config-if)#e
S1(config-if)#exit
S1(config)#interface vlan 30
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan30, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan30, changed state to up
S1(config-if)#ip address 192.168.30.254 255.255.255.0( configure gateway )
S1(config-if)#no shutdown
S1(config-if)#e
S1(config-if)#exit
S1(config)#ip routing ( Open routing )
S2( Two-layer switch ):
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host S2
Switch(config)#host S2
This part is VLAN Division Arrange according to the topology , Divide into vlan10、20、30
S2(config)#vlan 10
S2(config-vlan)#e
S2(config-vlan)#exit
S2(config)#vlan 20
S2(config-vlan)#e
S2(config-vlan)#exit
S2(config)#vlan 30
S2(config-vlan)#e
S2(config-vlan)#exit
This part divides the corresponding interfaces into corresponding VLAN
S2(config)#int f
S2(config)#int fastEthernet 0/1
S2(config-if)#sw
S2(config-if)#switchport mode
S2(config-if)#switchport mode ac
S2(config-if)#switchport mode access
S2(config-if)#sw
S2(config-if)#switchport ac
S2(config-if)#switchport access vlan 10
S2(config-if)#e
S2(config-if)#exit
S2(config)#int fastEthernet 0/2
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 20
S2(config-if)#e
S2(config-if)#exit
S2(config)#int fastEthernet 0/3
S2(config-if)#switchport mode access
S2(config-if)#switchport access vlan 30
S2(config-if)#end
S2#
%SYS-5-CONFIG_I: Configured from console by console
VLAN surface
S2#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/10, Fa0/11
Fa0/12, Fa0/13, Fa0/14, Fa0/15
Fa0/16, Fa0/17, Fa0/18, Fa0/19
Fa0/20, Fa0/21, Fa0/22, Fa0/23
Fa0/24, Gig0/1, Gig0/2
10 VLAN0010 active Fa0/1
20 VLAN0020 active Fa0/2
30 VLAN0030 active Fa0/3
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
S2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
To configure trunk mouth
S2(config)#int f
S2(config)#int fastEthernet 0/4
S2(config-if)#sw
S2(config-if)#switchport mod
S2(config-if)#switchport mode tr
S2(config-if)#switchport mode trunk
S2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up
S2(config-if)#end
result :
The result of the first step : identical VLAN Hosts of can interact ping through

The second step is to complete the result : Different VLAN The host between can communicate through the three-layer switch
ping PC2(192.168.20.1)
tracert It depends on where its bag goes
Pictured , After 192.168.10.254 That is, the route through the layer 3 switch .

This article is written here , Please point out any mistakes . thank !!!
边栏推荐
- 第一篇试水--*offer
- Unity鼠标控制摄像机拖拽、旋转、缩放(模拟编辑器摄像机功能)
- Unity3d:UGUI源碼,Rebuild優化
- C# 自定义集合
- Take go language as an example to explain [performance analysis] by analogizing detective reasoning
- Hcip-hcia knowledge review (II)
- HCIP---MGRE环境下的OSPF综合实验
- Hcip ---- relevant knowledge points of GRE protocol, mGRE environment and OSPF Protocol
- HCIP---BGP相关配置
- Unity在URP管线下使用TriLib插件加载模型材质不正确的问题
猜你喜欢
随机推荐
前缀和 LeetCode2100. 适合打劫银行的日子
Unity3D+moba+技能指示器(二)
[bootloader architecture and brushing process based on UDS service]
0回溯/动态规划中等 LeetCode526. 优美的排列
学习日记(路由与交换技术)——浮动静态路由和缺省路由
Unity3d:UGUI源碼,Rebuild優化
Explanation of websocket protocol
psutil监控的简单使用
OSPF综合实验
学习日记——(路由与交换技术)ACL访问控制列表
0数组 LeetCode605. 种花问题
SQL server performance analysis, view slow queries
PDF Online preview, use of pdf.js
Post form submission data limit
unity3d:Assetbundle模拟加载,同步加载,异步加载,依赖包加载,自动标签,AB浏览器,增量打包
post表单提交数据限制
深入解析Redis中的复制
学习日记——(路由与交换技术)DHCP(动态主机配置协议)
GameFramework:打包资源,打随app发布包,打包生成文件夹说明,上传资源至服务器,下载资源,GameFreamworkList.dat 与GameFrameworkVersion.dat
C #: TOPK: take the largest 100 before 10000 numbers, and sort the heap




![[AUTOSAR DCM 1. module introduction (DSL, DSD, DSP)]](/img/99/55b3162ad061fbd00145d0b6810592.png)




