交换机工作原理及命令

1交换机的四大功能

1.学习功能---数据帧经过交换机,交换机会自动学习数据帧的源mac地址
2.转发功能---- - --数据帧经过交换机,会在mac表中查找数据帧的目的mac,查找成功,会从相应的接口转发数据
3.查询功能(泛洪) ----- 数据帧经过交换机,会在mac表中查找数据帧的目的mac, 查找失败,会从所有接口转发相同数据(泛洪)
4.刷新功能----交换机默认300s刷新一次mac地址表
>>>>.原理解释
1.交换机有张表(mac地址表),一开始未通讯之前mac地址表是空的2.同一个局域网中的主机A去访问主机B
3.主机A会将自己的mac地址和对面的mac地址封装进数据帧自己的是源mac地址,对面的目的mac地址
4.交换机会收到主机A的请求,会主动学习源mac地址(主机A的),由于mac地址表中没有去往主机B的路,所以交换机会泛洪(广播)
5.当主机B收到广播会主动回复,其余主机会丢弃数据帧
6.当交换机收到主机B的回复 会主动去看 mac地址表,找到去往主机A的路,并且记录下主机B的mac地址和端口号7.下一次通信就直接

2交换机的工作原理

 

 3交换机的命令

华为交换机的三种视图:
<Huawei>用户视图
[Huawei]系统视图
[Huawei-Ethernet0/0/1]接口视图
[Huawei-vlan10]vlan视图
 
<Huawei>display version //查看版本号
Huawei Versatile Routing Platform Software
VRP (R) software, Version 5.110 (S3700 V200R001C00) VRP:华为设备的操作系统平台,装了这个系统之后可以支持很多协议,功能等
Copyright (c) 2000-2011 HUAWEI TECH CO., LTD //指明这是一个华为的设备
 
Quidway S3700-26C-HI Routing Switch uptime is 0 week, 0 day, 0 hour, 3 minutes //指明运行了多长时间,当你开启时开始计算
 
<Huawei>dis ver --->命令可以简写
 
<Huawei>display saved-configuration 使用display saved-configuration命令可以查看交换机下次启动时的配置文件信息
<Huawei>display current-configuration 交换机运行过程中正在生效的配置称为当前配置
<Huawei>display startup 交换机上电时,从默认存储路径中读取配置文件进行交换机的初始化操作,因此该配置文件中的配置称为初始配置
 
---- More ---- 当命令太多一页翻不完时出现more,可按空格和回车键继续看,不看了就ctrl+c
 
<Huawei>system-view 或 <Huawei>sys //进入系统视图
 
[Huawei]sysname sw1 或 [Huawei]sys sw1 //更改设备名,区分2个简写的sys代表的意思不同
 
[sw1]display bridge mac-address
System bridge MAC address: 4c1f-ccf1-10b5 //显示交换机mac地址
 
<Huawei>dis int Ethernet0/0/1 //查看接口详细信息,包括状态、mac地址等
Ethernet0/0/1 current state : UP
Line protocol current state : UP
Description:
Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 9216
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-ccf1-10b5
Last physical up time : 2021-02-19 17:04:16 UTC-08:00
Last physical down time : 2021-02-19 16:23:41 UTC-08:00
Current system time: 2021-02-19 17:09:28-08:00
Hardware address is 4c1f-ccf1-10b5
Last 300 seconds input rate 0 bytes/sec, 0 packets/sec
Last 300 seconds output rate 0 bytes/sec, 0 packets/sec
Input: 0 bytes, 0 packets
Output: 17017 bytes, 143 packets
Input:
Unicast: 0 packets, Multicast: 0 packets
Broadcast: 0 packets
Output:
Unicast: 0 packets, Multicast: 143 packets
Broadcast: 0 packets
Input bandwidth utilization : 0%
Output bandwidth utilization : 0%
 
 
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]display this //显示接口当前配置
 
[Huawei]quit //退回到上一层
<Huawei>
 
[Huawei-Ethernet0/0/1]return //如果跨层返回用return或ctrl+z
<Huawei>
 
<Huawei>save //保存设置
 
[Huawei]clear configuration interface e0/0/1 //清除接口的配置,需指定接口
 
<Huawei>reset saved-configuration——清除已保存的配置
<Huawei>reboot——重启(未保存的当前配置会消失)
 
?:命令帮助/命令提示
TAB键:命令补全
 
<Huawei>sys //设置用console线连接时永不超时,默认是10min
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0
 
直接在接口模式下切换到其他接口不用退出当前视图
[SW1]int e0/0/2
[SW1-Ethernet0/0/2]int e0/0/1
[SW1-Ethernet0/0/1]
 
查看mac地址表
<SW1>dis mac-address
 
配置双工模式及速率
[SW1-Ethernet0/0/1]undo negotiation auto #关闭自协商功能,默认是自动协商,需先关闭之后可手动设置速率
 
[SW1-Ethernet0/0/1]duplex full/half //full全双工,half半双工
 
[SW1-Ethernet0/0/1]speed 10/100 //配置接口速率10M/100M
 
 
<SW1>undo terminal monitor 关闭监视功能
Info: Current terminal monitor is off.
 
[R1]undo info-center enable 禁止弹出接口信息
Info: Information center is disabled.
 
 
想取消命令或者激活接口都可以使用undo
用户视图模式<Huawei>切换至系统视图模式[Huawei]
<Huawei>system-view
<Huawei>sys
退回用户视图
ctrl+z
[Huawei] quit
 
 
 
1、历史命令查询
[Huawei] display history-command
 
2、配置主机名
<Huawei> system-view
[Huawei] sysname Router1
 
3、状态信息查询
<Huawei>display version ####查看VRP版本
<Huawei>display users ####查看用户终端信息
 
4、进入接口模式并查看信息
<Huawei>sys
[Huawei]int e0/0/1
[Huawei-GigabitEthernet0/0/1]dis this ####查看当前视图下的配置信息
 
5、配置文件管理命令
[Huawei]display saved-configuration ###查看设备保存的信息
[Huawei]display current-configuration ###查看设备当前配置的信息
<SW1>save ###保存配置
<Huawei>reset saved-configuration ###擦除存储设备中的配置文件(初始化)
<Huawei>compare configuration ###比较当前配置信息与存储设备中的保存文件是否一致
 
6、关闭华为的信息提示中心
[Huawei]undo info-center enable
或者
<Huawei>undo terminal monitor
 
7、永不超时
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
 
8、配置双工及速率命令
<Huawei>sys
[Huawei]int g0/0/1
[SW1-Ethernet0/0/1]undo negotiation auto ###关闭自动协商
[SW1-Ethernet0/0/1]speed 100 ###调至速率100M
[SW1-Ethernet0/0/1]duplex full ###调至全双工模式, 解释:full:Full-Duplex(全双工模式) half:Half-Duplex(半双工模式)
 
9、保存配置
<Huawei>save
 
10、设置远程登录密码
[Huawei]user-interface vty 0 4 #0是初始值,4是结束值。表示可同时打开5个会话进入交换机去配置命令
[Huawei-ui-vty0-4]authentication-mode password
[Huawei-ui-vty0-4]set authentication password simple 222
[Huawei-ui-vty0-4]user privilege level 3
[Huawei-ui-vty0-4]dis this
 
 
用SecureCRT链接eNSP
●双击打开某台设备有【视图】和【配置】,打开【配置】---窗口配置:串口号:2000 ###这个是端口号
●打开SecureCRT 点击【链接】---【Protocol】Telnet----【Hostname】127.0.0.1----【Prot】2000
●当前终端被打开---断开【disconnect】----会话【session options】-----强制每次一个字符模式【Force charater at atime mode】---保存【OK】
●右击当前终端---链接【reconnect】

 

posted @   menglang  阅读(419)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示