华为交换机命令行操作小结
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,华为交换机命令行操作小结2016/10/20华为交换机命令行操作小结2016/10/20一、基础1、进入 system-view 模式system-viewEnter system view, ret
千家信息网最后更新 2026年10月31日华为交换机命令行操作小结
华为交换机命令行操作小结
2016/10/20
华为交换机命令行操作小结2016/10/20一、基础1、进入 system-view 模式system-viewEnter system view, return user view with Ctrl+Z.[Huawei]2、更改交换机名称[Huawei]sysname SW-ACC-CORE-1[SW-ACC-CORE-1]3、返回 user-view 模式[SW-ACC-CORE-1]return 4、查看配置启动配置 display saved-configuration当前配置 display current-configuration5、保存配置 saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Aug 31 2016 09:50:33-08:00 SW-ACC-CORE-1 %CFM/4/SAVE(l)[0]:The user chose Y when deciding whether to save the configuration to the device.Now saving the current configuration to the slot 0.Save the configuration successfully. 6、用户和管理1)配置密码采用password的方式来验证:authentication-mode password(简单,略过不提,看命令行的帮助即可)采用aaa的方式来验证: sys[SW-ACC-CORE-1]aaa[SW-ACC-CORE-1-aaa]local-user admin password cipher mypass[SW-ACC-CORE-1-aaa]local-user admin privilege level 3[SW-ACC-CORE-1-aaa]local-user admin service-type telnet terminal http ssh[SW-ACC-CORE-1-aaa]quit2)配置 console 的密码[SW-ACC-CORE-1]user-interface console 0[SW-ACC-CORE-1-ui-con0]authentication-mode aaa[SW-ACC-CORE-1-ui-con0]quit3)配置 vty 的密码来允许telnet服务[SW-ACC-CORE-1]user-interface vty 0 4[SW-ACC-CORE-1-ui-vty0-4]authentication-mode aaa[SW-ACC-CORE-1-ui-vty0-4]quit测试: telnet 192.168.200.254Trying 192.168.200.254 ...Press CTRL+K to abortConnected to 192.168.200.254 ...Login authenticationUsername:adminPassword:(输入:mypass)Info: The max number of VTY users is 5, and the number of current VTY users on line is 1. The current login time is 2016-08-31 16:49:07. 参考:http://support.huawei.com/enterprise/KnowledgebaseReadAction.action?contentId=KB1000125747&idAbsPath=7919710|21782164|21782167|6691579【特别注意】盒式(S2700&S3700&S5700&S6700)(一)、V200R003及之前的版本缺省情况下1.telnet server已启用2.user-interface vty下协议默认支持telnet所以该版本仅需配置上面的通用配置(二)、V200R005及之后的版本缺省情况下1.telnet server未启用2.user-interface vty下协议默认支持ssh所以该版本需按以下方法配置1.打开telnet服务telnet server enable2.用户接口下启用telnet协议user-interface vty 0 4protocol inbound telnet3.添加通用配置4)启用ssh参考:http://support.huawei.com/enterprise/KnowledgebaseReadAction.action?contentId=KB1000067691&idAbsPath=7919710%7C9856733%7C7923144%7C66915795)启用交换机的web服务 dir找到web文件(以这个为例:s5700si-v200r003c00.001.web.7z),加载: system-view http server load s5700si-v200r003c00.001.web.7z http secure-server enablehttps://ip/注:更改配置后,记得保存。7、系统管理1)版本 display version Huawei Versatile Routing Platform SoftwareVRP (R) software, Version 5.110 (S5700 V200R001C00)Copyright (c) 2000-2011 HUAWEI TECH CO., LTDQuidway S5700-28C-HI Routing Switch uptime is 0 week, 0 day, 0 hour, 15 minutes2)时间 display clock 2016-08-31 16:56:31-08:00WednesdayTime Zone(China-Standard-Time) : UTC-08:00二、VLAN1、创建vlan1)批量创建指定id的vlan[SW-ACC-CORE-1]vlan batch 10 20 30 402)批量创建指定id范围的vlan[SW-ACC-CORE-1]vlan batch 100 to 1092、设置业务口的模式并加入vlan[SW-ACC-CORE-1]interface GigabitEthernet 0/0/1[SW-ACC-CORE-1-GigabitEthernet0/0/1]port link-type access[SW-ACC-CORE-1-GigabitEthernet0/0/1]port default vlan 40[SW-ACC-CORE-1-GigabitEthernet0/0/1]quit如果想调整 link-type 为 trunk,怎么办?[SW-ACC-CORE-1-GigabitEthernet0/0/1]port link-type trunkError: Please renew the default configurations.此时应该这样操作:因为端口已经加入了vlan,需要先undo:[SW-ACC-CORE-1-GigabitEthernet0/0/1]undo port default vlan[SW-ACC-CORE-1-GigabitEthernet0/0/1]port link-type trunk运行多个vlan通过这个trunk链接:[SW-ACC-CORE-1-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 303、显示vlan[SW-ACC-CORE-1-vlan20]display vlanThe total number of vlans is : 15--------------------------------------------------------------------------------U: Up; D: Down; TG: Tagged; UT: Untagged;MP: Vlan-mapping; ST: Vlan-stacking;#: ProtocolTransparent-vlan; *: Management-vlan;--------------------------------------------------------------------------------VID Type Ports --------------------------------------------------------------------------------1 common UT:GE0/0/1(U) GE0/0/2(U) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D) 10 common 20 common TG:GE0/0/1(U) 30 common TG:GE0/0/1(U) 40 common 100 common 101 common 102 common 103 common 104 common 105 common 106 common 107 common 108 common 109 common VID Status Property MAC-LRN Statistics Description --------------------------------------------------------------------------------1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 30 enable default enable disable VLAN 0030 40 enable default enable disable VLAN 0040 100 enable default enable disable VLAN 0100 101 enable default enable disable VLAN 0101 102 enable default enable disable VLAN 0102 103 enable default enable disable VLAN 0103 104 enable default enable disable VLAN 0104 105 enable default enable disable VLAN 0105 106 enable default enable disable VLAN 0106 107 enable default enable disable VLAN 0107 108 enable default enable disable VLAN 0108 109 enable default enable disable VLAN 0109 4、给指定vlan配置虚接口[SW-ACC-CORE-1]interface Vlanif 20[SW-ACC-CORE-1-Vlanif20]ip address 172.30.0.1 255.255.192.0[SW-ACC-CORE-1-Vlanif20]quit[SW-ACC-CORE-1]interface Vlanif 30[SW-ACC-CORE-1-Vlanif30]ip address 172.30.64.1 255.255.192.0[SW-ACC-CORE-1-Vlanif30]quit同样的,可以给交换机配置管理IP(即vlan1):[SW-ACC-CORE-1]interface Vlanif 1[SW-ACC-CORE-1-Vlanif1]ip address 10.0.0.1 255.0.0.0还可以查看那当前的配置信息:[SW-ACC-CORE-1-Vlanif1]display thisInterface Vlanif 1 ip address 10.0.0.1 255.0.0.0[SW-ACC-CORE-1-Vlanif1]quit5、批量配置使用端口组来批量配置[SW-ACC-CORE-1]port-group 1[SW-ACC-CORE-1-port-group-1]group-member GigabitEthernet0/0/2 to GigabitEthernet0/0/24[SW-ACC-CORE-1-port-group-1]port link-type access[SW-ACC-CORE-1-port-group-1]port default vlan 20[SW-ACC-CORE-1-port-group-1]quit6、显示vlan接口信息[SW-ACC-CORE-1]display ip interface Vlanif 20Vlanif20 current state : UP Line protocol current state : UPThe Maximum Transmit Unit : 1500 bytesinput packets : 0, bytes : 0, multicasts : 0output packets : 0, bytes : 0, multicasts : 0Directed-broadcast packets: received packets: 0, sent packets: 0 forwarded packets: 0, dropped packets: 0 Internet Address is 172.30.0.1/18 Broadcast address : 172.30.63.255TTL being 1 packet number: 0TTL invalid packet number: 0ICMP packet input number: 0 Echo reply: 0 Unreachable: 0 Source quench: 0 Routing redirect: 0 Echo request: 0 Router advert: 0 Router solicit: 0 Time exceed: 0 IP header bad: 0 Timestamp request: 0 Timestamp reply: 0 Information request: 0 Information reply: 0 Netmask request: 0 Netmask reply: 0 Unknown type: 0 7、删除某个vlan清理接口上使用的vlan:[SW-ACC-CORE-1]int GigabitEthernet 0/0/2[SW-ACC-CORE-1-GigabitEthernet0/0/2]undo port trunk allow-pass vlan 20[SW-ACC-CORE-1-GigabitEthernet0/0/2]undo port link-type[SW-ACC-CORE-1-Vlanif20]quit清理vlanif的信息:[SW-ACC-CORE-1]int Vlanif 20[SW-ACC-CORE-1-Vlanif20]undo ip address[SW-ACC-CORE-1-Vlanif20]quit[SW-ACC-CORE-1]undo interface Vlanif 20清理vlan信息:[SW-ACC-CORE-1]undo vlan batch 208、关于 Access,Hybrid,Trunk 三种模式的理解请参考:http://support.huawei.com/ecommunity/bbs/10250727.html四、网络1、显示IP信息[SW-ACC-CORE-1]display ip interface brief*down: administratively down^down: standby(l): loopback(s): spoofingThe number of interface that is UP in Physical is 4The number of interface that is DOWN in Physical is 1The number of interface that is UP in Protocol is 4The number of interface that is DOWN in Protocol is 1Interface IP Address/Mask Physical Protocol MEth0/0/1 unassigned down down NULL0 unassigned up up(s) Vlanif1 10.0.0.1/8 up up Vlanif20 172.30.0.1/18 up up Vlanif30 172.30.64.1/18 up up 2、显示路由信息 [SW-ACC-CORE-1]display ip routing-tableRoute Flags: R - relay, D - download to fib------------------------------------------------------------------------------Routing Tables: Public Destinations : 8 Routes : 8 Destination/Mask Proto Pre Cost Flags NextHop Interface 10.0.0.0/16 Direct 0 0 D 10.0.0.1 Vlanif1 10.0.0.1/32 Direct 0 0 D 127.0.0.1 Vlanif1 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 172.30.0.0/18 Direct 0 0 D 172.30.0.1 Vlanif20 172.30.0.1/32 Direct 0 0 D 127.0.0.1 Vlanif20 172.30.64.0/18 Direct 0 0 D 172.30.64.1 Vlanif30 172.30.64.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 3、ACL[SW-ACC-CORE-1]acl ? INTEGER<2000-2999> Basic access-list(add to current using rules) INTEGER<3000-3999> Advanced access-list(add to current using rules) INTEGER<4000-4999> Specify a L2 acl group INTEGER<5000-5999> User defined access-list ipv6 ACL IPv6 name Specify a named ACL number Specify a numbered ACL 1)创建【流规则】[SW-ACC-CORE-1]acl 3001[SW-ACC-CORE-1-acl-adv-3001]rule deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255[SW-ACC-CORE-1-acl-adv-3001]quit【流分类】[SW-ACC-CORE-1]traffic classifier tc1[SW-ACC-CORE-1-classifier-tc1]if-match acl 3001[SW-ACC-CORE-1-classifier-tc1]quit【流行为】默认是permit[SW-ACC-CORE-1]traffic behavior tb1[SW-ACC-CORE-1-behavior-tb1]deny[SW-ACC-CORE-1-behavior-tb1]quit【流策略】[SW-ACC-CORE-1]traffic policy tp1[SW-ACC-CORE-1-trafficpolicy-tp1]classifier tc1 behavior tb1[SW-ACC-CORE-1-trafficpolicy-tp1]quit【在指定接口应用策略】[SW-ACC-CORE-1]int GigabitEthernet 0/0/2[SW-ACC-CORE-1-GigabitEthernet0/0/2]traffic-policy tp1 inbound[SW-ACC-CORE-1-GigabitEthernet0/0/2]quit【测试符合预期】PC>ping 172.30.0.111Ping 172.30.0.111: 32 data bytes, Press Ctrl_C to breakRequest timeout!Request timeout!Request timeout!PC>ping 172.30.64.222Ping 172.30.64.222: 32 data bytes, Press Ctrl_C to breakRequest timeout!From 172.30.64.222: bytes=32 seq=2 ttl=127 time=78 msFrom 172.30.64.222: bytes=32 seq=2 ttl=127 time=74 ms2)查看ACL现状【acl】[SW-ACC-CORE-1]display acl 3001Advanced ACL 3001, 1 ruleAcl's step is 5 rule 5 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255【classifier】[SW-ACC-CORE-1]display traffic classifier user-defined User Defined Classifier Information: Classifier: tc1 Operator: AND Rule(s) : if-match acl 3001 Total classifier number is 1 【behaviour】[SW-ACC-CORE-1]display traffic behavior user-defined User Defined Behavior Information: Behavior: tb1 DenyTotal behavior number is 1 【policy】[SW-ACC-CORE-1]display traffic policy user-defined User Defined Traffic Policy Information: Policy: tp1 Classifier: tc1 Operator: AND Behavior: tb1 DenyTotal policy number is 1 【applied-record】[SW-ACC-CORE-1]display traffic-policy applied-record #------------------------------------------------- Policy Name: tp1 Policy Index: 1 Classifier:tc1 Behavior:tb1 ------------------------------------------------- *interface GigabitEthernet0/0/2 traffic-policy tp1 inbound slot 0 : success------------------------------------------------- Policy total applied times: 1.#3)管理acl【增加1条规则】[SW-ACC-CORE-1]acl 3001[SW-ACC-CORE-1-acl-adv-3001]rule deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255[SW-ACC-CORE-1-acl-adv-3001]display acl 3001Advanced ACL 3001, 2 rulesAcl's step is 5 rule 5 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255 rule 10 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255【测试符合预期】PC>ping 172.30.0.111Ping 172.30.0.111: 32 data bytes, Press Ctrl_C to breakRequest timeout!Request timeout!Request timeout!PC>ping 172.30.64.222Ping 172.30.64.222: 32 data bytes, Press Ctrl_C to breakRequest timeout!Request timeout!Request timeout!【删除1条规则】[SW-ACC-CORE-1-acl-adv-3001]undo rule 5[SW-ACC-CORE-1-acl-adv-3001]display acl 3001Advanced ACL 3001, 1 ruleAcl's step is 5 rule 10 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255【测试符合预期】PC>ping 172.30.0.111Ping 172.30.0.111: 32 data bytes, Press Ctrl_C to breakRequest timeout!From 172.30.0.111: bytes=32 seq=2 ttl=127 time=62 msFrom 172.30.0.111: bytes=32 seq=2 ttl=127 time=64 msPC>ping 172.30.64.222Ping 172.30.64.222: 32 data bytes, Press Ctrl_C to breakRequest timeout!Request timeout!Request timeout!【再增加1条规则】[SW-ACC-CORE-1-acl-adv-3001]rule deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255[SW-ACC-CORE-1-acl-adv-3001]display acl 3001Advanced ACL 3001, 2 rulesAcl's step is 5 rule 10 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255 rule 15 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255注:rule id 递增的step为5,由于之前删除了id=5的rule,再新增则变成了15,如果先清空了这里规则,则还是从id=5开始递增。
配置
信息
交换机
接口
版本
规则
模式
测试
管理
命令
密码
参考
服务
小结
华为
情况
方式
用户
策略
支持
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网新科技
江苏根荣互联网科技
厦门中拓互联网络科技有限公司
麻工互联网科技
互联网 卓越科技
浩特互联网科技
西安互联网科技公司
菲比寻常互联网科技
中国互联网金融科技基金
科技互联网大厂
互联网科技商业
哈尔滨屹滨互联网科技有限公司
徐州市互联网科技有限公司
电子商务与互联网科技的关系
皮皮虾互联网科技有限公司
福州德业互联网科技
科技信息时代互联网发展
安徽零酒互联网科技有限公司
第三届互联网大会安防黑科技
互联网科技创业有什么好项目
互联网科技公司简介
云信互联网科技有限公司
互联网 科技公司
亿账通互联网科技
互联网 视角下的科技创新
互联网科技汛
金融科技与互联网金融相同和不同
明优互联网科技有限公司
福州德业互联网科技
互联网科技创新方面的资料