使用说明
- 本手册按品牌分章,命令不要跨品牌混用(同样是划 VLAN,华为用
port link-type access、思科用switchport mode access,写法不同)。 - 每个品牌分两章:命令速查表(免费公开) 与 配置步骤与避坑(登录后阅读)。
- 速查表只看「命令」和「用途」两列即可;「示例」是可直接改参数套用的样板。
- 配置详解含完整步骤、常见坑和验证方法,登录后全文可读。
- 命令来自厂商官方文档与项目已审模板,未经真机逐条验证;生产环境操作前请先备份配置。
一、命令速查表(序号 / 命令 / 用途 / 示例)
01 基础与系统管理命令
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 1 | system-view | 进入系统视图 | system-view |
| 2 | quit | 退出当前视图 | quit |
| 3 | return | 返回用户视图 | return |
| 4 | sysname SW1 | 修改设备名称 | sysname SW1 |
| 5 | save | 保存当前配置 | save |
| 6 | reboot | 重启设备 | reboot |
| 7 | display current-configuration | 查看当前配置 | display current-configuration |
| 8 | display version | 查看版本信息 | display version |
| 9 | display device | 查看设备硬件信息 | display device |
| 10 | display clock | 查看设备当前时间 | display clock |
| 11 | clock timezone Beijing add 08:00 | 配置时区 | clock timezone Beijing add 08:00 |
| 12 | clock datetime 2024-01-01 10:00:00 | 配置设备时间 | clock datetime 2024-01-01 10:00:00 |
| 13 | display logbuffer | 查看日志缓冲区 | display logbuffer |
| 14 | display this | 查看当前视图配置 | display this |
| 15 | display history-command | 查看历史命令 | display history-command |
| 16 | reset saved-configuration | 清除启动配置 | reset saved-configuration |
| 17 | screen-length 0 temporary | 临时关闭分页 | screen-length 0 temporary |
| 18 | header login information | 配置登录提示信息 | header login information |
| 19 | user-interface console 0 | 进入Console口视图 | user-interface console 0 |
| 20 | user-interface vty 0 4 | 进入VTY视图 | user-interface vty 0 4 |
| 21 | authentication-mode password | 配置密码认证 | authentication-mode password |
| 22 | set authentication password simple Huawei@123 | 设置VTY密码 | set authentication password simple Huawei@123 |
| 23 | stelnet server enable | 开启SSH服务 | stelnet server enable |
| 24 | ssh user admin service-type stelnet | 创建SSH用户 | ssh user admin service-type stelnet |
| 25 | display users | 查看在线用户 | display users |
02 接口与端口管理命令
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 26 | interface GigabitEthernet0/0/1 | 进入端口接口视图 | interface GigabitEthernet0/0/1 |
| 27 | description Uplink_to_Core | 配置接口描述 | description Uplink_to_Core |
| 28 | undo shutdown | 启用端口 | undo shutdown |
| 29 | shutdown | 关闭端口 | shutdown |
| 30 | display interface GigabitEthernet0/0/1 | 查看端口详细状态 | display interface GigabitEthernet0/0/1 |
| 31 | display interface brief | 查看接口状态摘要 | display interface brief |
| 32 | speed 1000 | 配置端口速率 | speed 1000 |
| 33 | duplex full | 配置全双工 | duplex full |
| 34 | negotiation auto | 自动协商速率与双工 | negotiation auto |
| 35 | mtu 1500 | 配置MTU | mtu 1500 |
| 36 | flow-control enable | 开启流控 | flow-control enable |
| 37 | loopback-detect enable | 开启环路检测 | loopback-detect enable |
| 38 | port link-type access | 设置为Access口 | port link-type access |
| 39 | port default vlan 10 | 配置Access口默认VLAN | port default vlan 10 |
| 40 | port link-type trunk | 设置为Trunk口 | port link-type trunk |
| 41 | port trunk allow-pass vlan 10 20 30 | 配置Trunk口VLAN | port trunk allow-pass vlan 10 20 30 |
| 42 | port link-type hybrid | 设置为Hybrid口 | port link-type hybrid |
| 43 | port hybrid tagged vlan 10 20 | 配置Hybrid tagged VLAN | port hybrid tagged vlan 10 20 |
| 44 | port hybrid untagged vlan 30 | 配置Hybrid untagged VLAN | port hybrid untagged vlan 30 |
| 45 | display port vlan | 查看端口VLAN信息 | display port vlan |
| 46 | display counters interface GigabitEthernet0/0/1 | 查看接口计数器 | display counters interface GigabitEthernet0/0/1 |
| 47 | display transceiver interface GigabitEthernet0/0/1 | 查看光模块信息 | display transceiver interface GigabitEthernet0/0/1 |
| 48 | reset counters interface GigabitEthernet0/0/1 | 清零接口计数器 | reset counters interface GigabitEthernet0/0/1 |
03 VLAN与二层交换命令
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 49 | vlan batch 10 20 30 | 批量创建VLAN | vlan batch 10 20 30 |
| 50 | vlan 10 | 进入VLAN视图 | vlan 10 |
| 51 | name Finance | 配置VLAN名称 | name Finance |
| 52 | display vlan | 查看VLAN信息 | display vlan |
| 53 | display mac-address | 查看MAC地址表 | display mac-address |
| 54 | display mac-address dynamic | 查看动态MAC表 | display mac-address dynamic |
| 55 | display mac-address static | 查看静态MAC表 | display mac-address static |
| 56 | mac-address static 0001-0002-1234 vlan 10 interface GigabitEthernet0/0/1 | 配置静态MAC绑定 | mac-address static 0001-0002-1234 vlan 10 interface GigabitEthernet0/0/1 |
| 57 | mac-address learning disable | 关闭端口MAC学习 | mac-address learning disable |
| 58 | mac-address max-mac-count 200 | 限制端口MAC数量 | mac-address max-mac-count 200 |
| 59 | display arp | 查看ARP表 | display arp |
| 60 | arp static 192.168.10.2 00e0-29ff-5678 | 配置静态ARP | arp static 192.168.10.2 00e0-29ff-5678 |
| 61 | interface Vlanif10 | 进入Vlanif接口 | interface Vlanif10 |
| 62 | ip address 192.168.10.1 24 | 配置Vlanif接口IP | ip address 192.168.10.1 24 |
| 63 | display ip interface brief | 查看三层接口摘要 | display ip interface brief |
| 64 | port-isolate enable | 开启端口隔离 | port-isolate enable |
| 65 | port-isolate group 1 | 配置端口隔离组 | port-isolate group 1 |
| 66 | display port-isolate | 查看端口隔离配置 | display port-isolate |
| 67 | voice-vlan 20 enable | 开启Voice VLAN | voice-vlan 20 enable |
| 68 | display mac-address aging-time | 查看MAC老化时间 | display mac-address aging-time |
| 69 | storm-suppression broadcast 1000 | 控制广播风暴 | storm-suppression broadcast 1000 |
| 70 | display stp brief | 查看生成树简表 | display stp brief |
| 71 | display lldp neighbor brief | 查看LLDP邻居 | display lldp neighbor brief |
| 72 | lldp enable | 开启LLDP | lldp enable |
04 链路聚合与生成树命令
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 73 | interface Eth-Trunk 1 | 创建聚合接口 | interface Eth-Trunk 1 |
| 74 | trunkport GigabitEthernet0/0/1 | 把接口加入聚合口 | trunkport GigabitEthernet0/0/1 |
| 75 | trunkport GigabitEthernet0/0/2 | 另一个接口加入聚合口 | trunkport GigabitEthernet0/0/2 |
| 76 | mode lacp-static | 配置LACP静态模式 | mode lacp-static |
| 77 | display eth-trunk 1 | 查看Eth-Trunk状态 | display eth-trunk 1 |
| 78 | display lacp peer | 查看LACP对端信息 | display lacp peer |
| 79 | load-balance src-dst-ip | 配置负载分担方式 | load-balance src-dst-ip |
| 80 | stp enable | 开启STP | stp enable |
| 81 | stp mode mstp | 配置MSTP模式 | stp mode mstp |
| 82 | stp edged-port enable | 配置边缘端口 | stp edged-port enable |
| 83 | stp bpdu-protection enable | 开启BPDU保护 | stp bpdu-protection enable |
| 84 | stp root-protection enable | 开启根保护 | stp root-protection enable |
| 85 | stp tc-protection enable | 开启TC保护 | stp tc-protection enable |
| 86 | stp instance 1 root primary | 实例1主根桥 | stp instance 1 root primary |
| 87 | stp instance 1 root secondary | 实例1备根桥 | stp instance 1 root secondary |
| 88 | display stp interface GigabitEthernet0/0/1 | 查看端口STP状态 | display stp interface GigabitEthernet0/0/1 |
| 89 | display stp topology-change | 查看拓扑变化记录 | display stp topology-change |
| 90 | stp region-configuration | 进入MST域配置视图 | stp region-configuration |
| 91 | region-name campus | 配置MST域名 | region-name campus |
| 92 | revision-level 1 | 配置修订号 | revision-level 1 |
| 93 | instance 1 vlan 10 20 30 | 绑定实例与VLAN | instance 1 vlan 10 20 30 |
| 94 | active region-configuration | 激活MST域配置 | active region-configuration |
| 95 | display mstp region-configuration | 查看MST域配置 | display mstp region-configuration |
05 三层路由与动态路由命令
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 96 | system-view | 进入系统视图 | system-view |
| 97 | interface Vlanif10 | 创建三层网关接口 | interface Vlanif10 |
| 98 | ip address 192.168.10.1 24 | 配置网关IP | ip address 192.168.10.1 24 |
| 99 | undo shutdown | 启用Vlanif接口 | undo shutdown |
| 100 | interface LoopBack0 | 创建Loopback接口 | interface LoopBack0 |
| 101 | ip address 10.10.10.10 32 | 配置Loopback地址 | ip address 10.10.10.10 32 |
| 102 | display ip routing-table | 查看路由表 | display ip routing-table |
| 103 | ip route-static 0.0.0.0 0.0.0.0 192.168.1.254 | 配置默认路由 | ip route-static 0.0.0.0 0.0.0.0 192.168.1.254 |
| 104 | ip route-static 10.10.0.0 16 192.168.1.2 | 配置静态路由 | ip route-static 10.10.0.0 16 192.168.1.2 |
| 105 | undo ip route-static 10.10.0.0 16 | 删除静态路由 | undo ip route-static 10.10.0.0 16 |
| 106 | display ip routing-table protocol static | 查看静态路由 | display ip routing-table protocol static |
| 107 | ping 192.168.1.1 | 测试连通性 | ping 192.168.1.1 |
| 108 | tracert 8.8.8.8 | 路由路径跟踪 | tracert 8.8.8.8 |
| 109 | ospf 1 | 进入OSPF进程 | ospf 1 |
| 110 | router-id 1.1.1.1 | 配置Router ID | router-id 1.1.1.1 |
| 111 | area 0 | 进入区域0 | area 0 |
| 112 | network 10.0.0.0 0.0.0.255 | 宣告网段到OSPF | network 10.0.0.0 0.0.0.255 |
| 113 | display ospf peer | 查看OSPF邻居状态 | display ospf peer |
| 114 | display ospf interface | 查看OSPF接口 | display ospf interface |
| 115 | rip 1 | 进入RIP进程 | rip 1 |
| 116 | version 2 | 配置RIP版本 | version 2 |
| 117 | network 192.168.1.0 | 宣告网段到RIP | network 192.168.1.0 |
| 118 | display rip 1 route | 查看RIP路由 | display rip 1 route |
| 119 | display fib | 查看FIB转发表 | display fib |
06 DHCP、ACL与安全排障命令
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 120 | dhcp enable | 开启DHCP服务 | dhcp enable |
| 121 | ip pool office | 创建地址池 | ip pool office |
| 122 | network 192.168.10.0 mask 255.255.255.0 | 配置地址池网段 | network 192.168.10.0 mask 255.255.255.0 |
| 123 | gateway-list 192.168.10.1 | 配置默认网关 | gateway-list 192.168.10.1 |
| 124 | dns-list 114.114.114.114 | 配置DNS地址 | dns-list 114.114.114.114 |
| 125 | lease day 7 | 配置租期 | lease day 7 |
| 126 | interface Vlanif10 | 进入网关接口 | interface Vlanif10 |
| 127 | dhcp select global | 接口应用全局地址池 | dhcp select global |
| 128 | display ip pool | 查看地址池信息 | display ip pool |
| 129 | display dhcp server statistics | 查看DHCP统计 | display dhcp server statistics |
| 130 | display dhcp server ip-in-use | 查看已分配IP | display dhcp server ip-in-use |
| 131 | display arp all | 查看ARP验证结果 | display arp all |
| 132 | acl number 3000 | 创建高级ACL | acl number 3000 |
| 133 | rule permit ip source 192.168.1.0 0.0.0.255 | 允许指定源网段 | rule permit ip source 192.168.1.0 0.0.0.255 |
| 134 | rule deny ip source any | 拒绝其他 | rule deny ip source any |
| 135 | display acl 3000 | 查看ACL详情 | display acl 3000 |
| 136 | traffic classifier C1 | 创建流分类器 | traffic classifier C1 |
| 137 | traffic behavior B1 | 创建流行为 | traffic behavior B1 |
| 138 | traffic policy P1 | 创建流策略 | traffic policy P1 |
| 139 | traffic-policy P1 inbound | 接口入方向应用策略 | traffic-policy P1 inbound |
| 140 | port-security enable | 开启端口安全 | port-security enable |
| 141 | dhcp snooping enable | 开启DHCP Snooping | dhcp snooping enable |
| 142 | display cpu-usage | 查看CPU占用率 | display cpu-usage |
| 143 | display memory-usage | 查看内存使用率 | display memory-usage |
> 本章速查表共 143 条命令。
附录 · 跨品牌速记
| 场景 | 华为 | 华三 | 思科 | 锐捷 |
|---|---|---|---|---|
| 进入系统视图 | system-view | system-view | configure terminal | configure terminal |
| 保存配置 | save | save force | write memory | write |
| 设为 Access 口 | port link-type access | port link-type access | switchport mode access | switchport mode access |
| 设为 Trunk 口 | port link-type trunk | port link-type trunk | switchport mode trunk | switchport mode trunk |
| 查看路由表 | display ip routing-table | display ip routing-table | show ip route | show ip route |
| 查看 MAC 表 | display mac-address | display mac-address | show mac address-table | show mac-address-table |
| 看 CPU | display cpu-usage | display cpu-usage | show processes cpu | show cpu |
| 删除/撤销 | undo | undo | no | no |