华为交换机常见命令.docx
《华为交换机常见命令.docx》由会员分享,可在线阅读,更多相关《华为交换机常见命令.docx(13页珍藏版)》请在冰豆网上搜索。
华为交换机常见命令
一、清空配置:
resetsaved-configuration(清楚下次启动时使
用的配置文件信息)然后重启设备,重启设备室提示保存信息,选择“NO”。
resetsaved-configuration
Warning:
Theactionwilldeletethe
savedconfigurationinthedevice.Theconfigurationwillbeerasedto
reconfigure.Continue?
[Y/N]:
yWarning:
Nowclearingtheconfigurationin
thedevice.
Info:
Succeededinclearingtheconfigurationinthedevice.
reboot
Info:
Thesystemisnowcomparingtheconfiguration,please
wait.
Warning:
Theconfigurationhasbeenmodified,anditwillbesavedto
thenextstartupsaved-configurationfileflash:
/vrpcfg.zip.Continue?
[Y/N]:
n//此处请选择“N”
Info:
Ifwanttorebootwithsavingdiagnostic
information,input'N'andthenexecute'rebootsavediagnostic-
information'.
Systemwillreboot!
Continue?
[Y/N]:
y
二、通过STelnet/Telnet登录交换机设置新的Console口登录密码
#以登录用户界面的认证方式为密码认证,密码为Huawei@123为例,配置如下。
system-view
[HUAWEI]user-interfaceconsole0
[HUAWEI-ui-console0]authentication-modepassword
[HUAWEI-ui-console0]setauthenticationpasswordcipherHuawei@123
[HUAWEI-ui-console0]return
save
#以登录用户界面的认证方式为AAA认证,用户名为admin123,密码为Huawei@123为
例,配置如下。
system-view
[HUAWEI]user-interfaceconsole0
[HUAWEI-ui-console0]authentication-modeaaa
[HUAWEI-ui-console0]quit
[HUAWEI]aaa
[HUAWEI-aaa]local-useradmin123passwordirreversible-cipherHuawei@123
[HUAWEI-aaa]local-useradmin123service-typeterminal(本地防务终端用户)
[HUAWEI-aaa]return(返回)
save(保存)
三、查看某个接口学习到的MAC地址
displaymac-addressdynamicgigabitethernet1/0/1
MACAddressVLAN/VSILearned-FromType
-------------------------------------------------------------------------
0000-0000-0003300/-GE1/0/1dynamic
0026-6e5c-feac3000/-GE1/0/1dynamic
四、查看某个VLAN学习到的MAC地址
displaymac-addressdynamicvlan10
MACAddressVLAN/VSILearned-FromType
--------------------------------------------------------------------------
0000-0000-000310/-GE1/0/1dynamic
0026-6e5c-feac10/-GE1/0/2dynamic
五、查看系统的MAC地址
displayinterfacegigabitethernet1/0/1
GigabitEthernet1/0/1currentstate:
UP
Lineprotocolcurrentstate:
UP
Description:
SwitchPort,Link-type:
access(configured),
IPSendingFrames'FormatisPKTFMT_ETHNT_2,Hardwareaddressis00e0f74b-
6d00
六、根据IP获取对应设备的MAC地址
displayarp|include192.168.150.20
配置端口安全
#配置GE1/0/1接口的端口安全功能。
system-view
[HUAWEI]interfacegigabitethernet1/0/1
[HUAWEI-GigabitEthernet1/0/1]port-securityenable
#配置GE1/0/1接口的MAC地址学习限制数为5,即最多可以学习到5个MAC地址表项。
system-view
[HUAWEI]interfacegigabitethernet1/0/1
[HUAWEI-GigabitEthernet1/0/1]port-securityenable
[HUAWEI-GigabitEthernet1/0/1]port-securitymax-mac-num5
配置永久端口组
#配置接口GE1/0/1至GE1/0/8加入到永久端口组portgroup1(使用port-group命令)
system-view
[HUAWEI]port-groupportgroup1
[HUAWEI-port-group-portgroup1]group-membergigabitethernet1/0/1to
gigabitethernet1/0/8
配置接口速率自协商模式下,手动配置接口速率
#配置以太网接口GE1/0/1在自协商模式下协商速率为100Mbit/s。
system-view
[HUAWEI]interfacegigabitethernet1/0/1
[HUAWEI-GigabitEthernet1/0/1]negotiationauto
[HUAWEI-GigabitEthernet1/0/1]autospeed100
配置双工模式自协商模式下,手动配置双工模式
#配置以太网电接口GE1/0/1在自协商模式下双工模式为全双工模式。
system-view
[HUAWEI]interfacegigabitethernet1/0/1
[HUAWEI-GigabitEthernet1/0/1]negotiationauto
[HUAWEI-GigabitEthernet1/0/1]autoduplexfull
配置接口切换到三层模式
接口视图下执行命令undoportswitch,配置接口切换到三层模式。
#将接口GE1/0/1切换为三层模式。
system-view
[HUAWEI]interfacegigabitethernet1/0/1
[HUAWEI-GigabitEthernet1/0/1]undoportswitch
[HUAWEI-GigabitEthernet1/0/1]ipaddress10.10.10.10255.255.255.0
支持二层模式与三层模式切换的款型及版本如下:
lS5700EI:
V200R005C00&C01
lS5700HI:
V100R005C01、V100R006C01、V200R001C00、V200R002C00、V200R003C00
、V200R005C00&C01
lS5710EI:
V200R002C00、V200R003C00、V200R005C00
lS5720EI:
V200R007C00、V200R008C00、V200R009C00、V200R010C00lS5710HI:
V200R003C00、
V200R005C00
lS5720HI:
V200R006C00、V200R007C00、V200R008C00、V200R009C00、
V200R010C00
lS6700EI:
V200R005C00&C01
lS6720EI:
V200R008C00、V200R009C00、
V200R010C00lS6720S-EI:
V200R008C00、V200R009C00、V200R010C00
l
S7700&S9700:
V200R001C00&C01、V200R002C00、V200R003C00、
V200R005C00、V200R006C00、
V200R007C00、V200R008C00、V200R009C00、V200R010C00
对于V200R005C00及后续版
本,在接口使用命令undoportswitch,将以太网接口从二层模式切换到三层模式后
,支持配置IP地址。
一键清除接口下的配置执行命令一键式清除接口下配置后,接口的状态将被置为
shutdown状态。
#在系统视图下执行命令clearconfigurationinterface清除GE1/0/1接口下的配置
system-view
[HUAWEI]clearconfigurationinterfacegigabitethernet1/0/1
Warning:
All
configurationsoftheinterfacewillbecleared,anditsstatewillbe
shutdown.Continue?
[Y/N]:
y
Info:
Total5command(s)executed,5successful,0failed.
查看设备支持的链路聚合组数目和成员接口数目
#查看设备支持的链路聚合组数目和成员接口数目。
displaytrunkconfiguration
接口加入VLAN
l
Access接口加入VLAN
system-view
[HUAWEI]interfacegigabitethernet0/0/1
[HUAWEI-GigabitEthernet0/0/1]portlink-typeaccess//设置接口的链路类型
为Access
[HUAWEI-GigabitEthernet0/0/1]portdefaultvlan10//把接口
GigabitEthernet0/0/1加入VLAN10
Trunk接口加入VLAN
system-view
[HUAWEI]interfacegigabitethernet0/0/1
[HUAWEI-GigabitEthernet0/0/1]portlink-typetrunk//设置接口的链路类型为
Trunk
[HUAWEI-GigabitEthernet0/0/1]porttrunkallow-passvlan10//把接口
GigabitEthernet0/0/1加入VLAN10
Hybrid接口加入VLAN
system-view
[HUAWEI]interfacegigabitethernet0/0/1
[HUAWEI-GigabitEthernet0/0/1]portlink-typehybrid//设置接口的链路类型
为Hybrid
[HUAWEI-GigabitEthernet0/0/1]porthybridtaggedvlan10//接口
GigabitEthernet0/0/1以Tagged方式加入VLAN10
HUAWEI-GigabitEthernet0/0/1]porthybriduntaggedvlan20//接口
GigabitEthernet0/0/1以Untagged方式加入VLAN20
批量创建VLAN
批量创建10个连续的VLAN:
VLAN11到VLAN20。
system-view
[HUAWEI]vlanbatch11to20
批量创建10不连续的VLAN:
VLAN10、VLAN15到VLAN19、VLAN25、VLAN28到VLAN30。
system-view
[HUAWEI]vlanbatch1015to192528to30
接口批量加入VLAN
access接口类型。
system-view
[HUAWEI]port-grouppg1//创建端口组pg1
[HUAWEI-port-group-pg1]group-membergigabitethernet1/0/1to
gigabitethernet1/0/5//把接口gigabitethernet1/0/1到gigabitethernet1/0/5加
入端口组
[HUAWEI-port-group-pg1]portlink-typeaccess//批量修改端口
gigabitethernet1/0/1togigabitethernet1/0/5的链路类型为access
[HUAWEI-port-group-pg1]portdefaultvlan10//批量把端口
gigabitethernet1/0/1togigabitethernet1/0/5加入VLAN10
trunk接口类型。
system-view
[HUAWEI]port-grouppg1//创建端口组pg1
[HUAWEI-port-group-pg1]group-membergigabitethernet1/0/1to
gigabitethernet1/0/5//把接口gigabitethernet1/0/1到gigabitethernet1/0/5加
入端口组
[HUAWEI-port-group-pg1]portlink-typetrunk//批量修改端口
gigabitethernet1/0/1togigabitethernet1/0/5的链路类型为trunk
[HUAWEI-port-group-pg1]porttrunkallow-passvlan1020//批量把端口
gigabitethernet1/0/1togigabitethernet1/0/5加入VLAN10和VLAN20
删除单个VLAN10。
system-view
[HUAWEI]undovlan10
删除批量VLAN10到VLAN20。
system-view
[HUAWEI]undovlanbatch10to20
将接口类型修改为Access
system-view
[HUAWEI]interfacegigabitethernet0/0/1
[HUAWEI-GigabitEthernet0/0/1]portlink-typeaccess
[HUAWEI-GigabitEthernet0/0/1]portdefaultvlan10//设置接口的PVID为
VLAN10,并同时将VLAN10加入接口
将接口类型修改为Trunk
system-view
[HUAWEI]interfacegigabitethernet0/0/1
[HUAWEI-GigabitEthernet0/0/1]portlink-typetrunk
[HUAWEI-GigabitEthernet0/0/1]porttrunkpvidvlan10//设置接口的PVID为
VLAN10
[HUAWEI-GigabitEthernet0/0/1]porttrunkallow-passvlan21020//将
VLAN2、VLAN10和VLAN20加入接口