这里写目录标题
一.mac地址格式
数据链路层作用 建立 维护 拆除
帧传输同步
差错恢复
流量控制
mac地址用来识别一个以太网上的某个单独或者一组设备
1.mac地址的地址长度
48bit,表现为16进制
前24bit为厂家的编码
后24位为某批次的网卡
2.mac地址的第8个bit
如果为0,表示单播mac地址
为1表示组播mac地址
3.发送数据的3种方法
单播–一对一通信
组播–一对部分感兴趣设备
广播–一对所有设备–系统的广告
4.Ethernet封装格式
二.交换机转发原理
1.转发过程
初始状态
mac地址学习
广播未知数据帧
接收方回应
交换机实现单播通信
文字描述:第一次通信时,交换机处于初始状态,mac地址表的表项为空
当PC1想与PC2进行通信时,PC1会发送一个数据帧,内容:源mac地址11-11-11 目的mac地址22-22-22
当数据帧经过交换机,交换机会拆开数据帧,分析源目的mac地址,自动将源mac地址和接口号写入表项中,
然后去表项种查找,从几号接口去往目的mac地址,发现表中没有直接广播(除了发送接口)只有目的mac地址
的设备会回包,其余接口的设备会丢弃,回复方PC2也会发送一个数据帧,内容:源mac地址22-22-22 目的mac地址11-11-11 。该数据帧经过交换机,交换机会将源mac地址和接口号写入mac地址表自动学习
然后会去mac地址表查找去往目的地址的接口号,发现表项中有,并且是一号接口直接发出给PC1
由于交换机中mac地址表中有了PC1,PC2的相关信息,所以下次PC1 PC2通信直接单播
2.交换机功能
自动学习:自动学习数据帧的源mac地址
转发:根据mac地址表转发数据
查询(泛洪):如果找不到转发的路径,广播
刷新:300s。定期刷新(删除)表项,节约硬件资源。
3.华为交换机命令
华为交换机的三种视图:
<>用户视图
[]系统视图
[-Ethernet0/0/1]接口视图
[-vlan10]vlan视图
<>display version //查看版本号 dis ver
<Huawei>display version //查看版本号
Huawei Versatile Routing Platform Software
VRP (R) software, Version 5.130 (AR2200 V200R003C00)
Copyright (C) 2011-2012 HUAWEI TECH CO., LTD
Huawei AR2220 Router uptime is 0 week, 0 day, 0 hour, 0 minute
BKP 0 version information:
1. PCB Version : AR01BAK2A VER.NC
2. If Supporting PoE : No
3. Board Type : AR2220
4. MPU Slot Quantity : 1
5. LPU Slot Quantity : 6
MPU 0(Master) : uptime is 0 week, 0 day, 0 hour, 0 minute
MPU version information :
1. PCB Version : AR01SRU2A VER.A
2. MAB Version : 0
3. Board Type : AR2220
4. BootROM Version : 0
<>system-view 或 <>sys //进入系统视图
[]sysname r1 或 []sys r1 //更改设备名,区分2个简写的sys代表的意思不同
[]display bridge mac-address //显示交换机mac地址
<Huawei>system-view //进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname r1 //更改设备名
[r1]display bridge mac-address // 显示交换机mac地址
System bridge MAC address: 00e0-fca9-0fca
<>dis int Ethernet x/x/x 或GigabitEthernet x/x/x //查看接口详细信息,包括状态、mac地址等
<r1>dis int GigabitEthernet 0/0/0 //查看接口详细信息,包括状态、mac地址等
GigabitEthernet0/0/0 current state : UP
Line protocol current state : DOWN
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet protocol processing : disabled
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fca9-0fca
Last physical up time : 2023-07-05 18:55:11 UTC-08:00
Last physical down time : 2023-07-05 18:55:07 UTC-08:00
Current system time: 2023-07-05 19:03:05-08:00
Port Mode: FORCE COPPER
Speed : 1000, Loopback: NONE
Duplex: FULL, Negotiation: ENABLE
Mdi : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 0 bits/sec,Record time: -
Output peak rate 0 bits/sec,Record time: -
Input: 0 packets, 0 bytes
Unicast: 0, Multicast: 0
Broadcast: 0, Jumbo: 0
Discard: 0, Total Error: 0
CRC: 0, Giants: 0
---- More ----当命令太多一页翻不完时出现more,可按空格和回车键继续看,不看了就ctrl+c
[]int e x/x/x 或g x/x/x //切换接口
[]display this //显示接口当前配置
[r1]int g 0/0/0 //切换接口
[r1-GigabitEthernet0/0/0]display this //显示接口当前配置
[V200R003C00]
#
interface GigabitEthernet0/0/0
#
return
<>save //保存设置
<r1>save //保存设置
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
[]clear configuration interface e或g x/x/x //清除接口的配置,需指定接口
[r1]clear configuration interface g0/0/0 //清除接口的配置,需指定接口
Warning: All configurations of the interface will be cleared, and its state will
be shutdown. Continue? [Y/N] :
<>reset saved-configuration——清除已保存的配置
<>reboot——重启(未保存的当前配置会消失)
?:命令帮助/命令提示
TAB键:命令补全
直接在接口模式下切换到其他接口不用退出当前视图
<>dis mac-address //查看mac地址表
<r1>dis mac-address
-------------------------------------------------------------------------------
MAC Address VLAN/Bridge Learned-From Type
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Total items displayed = 0
<r1>
<>undo terminal monitor //关闭监视功能 u t m
<r1>undo terminal monitor //关闭监视功能
Info: Current terminal monitor is off.
[]undo info-center enable //禁止弹出接口信息
[r1]undo info-center enable //禁止弹出接口信息
Info: Information center is disabled.
想取消命令或者激活接口都可以使用undo
[] display history-command //历史命令查询
[r1]display history-command //历史命令查询
sys
ys
[r1]
[]display saved-configuration //查看设备保存的信息
[r1]display saved-configuration //查看设备保存的信息
[V200R003C00]
#
sysname r1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
---- More ----
[ ]display current-configuration //查看设备当前配置的信息
[r1]display current-configuration //查看设备当前配置的信息
[V200R003C00]
#
sysname r1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
---- More ----
<>save //保存配置
<>reset saved-configuration //擦除存储设备中的配置文件(初始化)
<r1>reset saved-configuration //擦除存储设备中的配置文件(初始化)
This will delete the configuration in the flash memory.
The device configuratio
ns will be erased to reconfigure.
Are you sure? (y/n)[n]:
<>compare configuration //比较当前配置信息与存储设备中的保存文件是否一致
<r1>compare configuration //比较当前配置信息与存储设备中的保存文件是否一致
The current configuration is not the same as the next startup configuration fil
e.
====== Current configuration line 9 ======
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
====== Configuration file line 9 ======
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
<r1>
<>display saved-configuration // 可以查看交换机下次启动时的配置文件信息
<r1>display saved-configuration // 可以查看交换机下次启动时的配置文件信息
[V200R003C00]
#
sysname r1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
---- More ----
<>display current-configuration //交换机运行过程中正在生效的配置称为当前配置
<r1>display current-configuration //交换机运行过程中正在生效的配置称为当前配置
[V200R003C00]
#
sysname r1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
---- More ----
<>display startup ///交换机上电时,从默认存储路径中读取配置文件进行交换机的初始化操作,因此该配置文件中的配置称为初始配置
<r1>display startup
MainBoard:
Startup system software: null
Next startup system software: null
Backup system software for next startup: null
Startup saved-configuration file: flash:/vrpcfg.zip
Next startup saved-configuration file: flash:/vrpcfg.zip
Startup license file: null
Next startup license file: null
Startup patch package: null
Next startup patch package: null
Startup voice-files: null
Next startup voice-files: null