一、命令速查表(序号 / 命令 / 用途 / 示例)
第 1 页 · 基础配置与端口开局
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 1 | system-view | 进入系统配置视图 | system-view |
| 2 | sysname {hostname} | 设置设备主机名 | sysname H3C-SW1 |
| 3 | local-user {username} class manage | 建本地账号(network-admin 权限,仅用于 SSH) | local-user admin class manage |
| 4 | ssh server enable | 开启 SSH 服务(前提:已有本地密钥) | ssh server enable |
| 5 | authentication-mode scheme | VTY 0-4 只允许 SSH、走本地账号认证 | authentication-mode scheme |
| 6 | save force | 强制保存当前配置 | save force |
| 7 | vlan batch {vlan_ids} | 批量创建 VLAN | vlan batch 10 20 30 |
| 8 | vlan {vlan_id} | 创建 VLAN 并命名 | vlan 10 |
| 9 | undo vlan batch {vlan_ids} | 删除 VLAN | undo vlan batch 10 20 |
| 10 | port link-type access | 端口设为 Access 并划入 VLAN | port link-type access |
| 11 | port link-type trunk | 端口设为 Trunk,放行指定 VLAN | port link-type trunk |
| 12 | undo shutdown | 启用端口 | undo shutdown |
| 13 | qos lr inbound cir {cir_kbps} | 端口入方向限速 Kbps | qos lr inbound cir 10000 |
| 14 | port-isolate enable | 开启端口隔离(端口之间互不通) | port-isolate enable |
| 15 | undo port-isolate enable | 关闭端口隔离 | undo port-isolate enable |
| 16 | undo port access vlan | 撤销端口 Access VLAN 归属 | undo port access vlan |
| 17 | undo port trunk permit vlan {allowed_vlans} | 撤销 Trunk 放行的 VLAN | undo port trunk permit vlan 10 |
| 18 | shutdown | 关闭端口 | shutdown |
| 19 | speed {speed} | 设置端口速率与双工 | speed 1000 |
| 20 | port link-aggregation group {trunk_id} | 端口加入聚合组 | port link-aggregation group 1 |
| 21 | link-aggregation mode dynamic | 创建链路聚合组(LACP) | link-aggregation mode dynamic |
第 2 页 · 防环、三层网关与路由
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 22 | stp bpdu-protection | 开 BPDU 保护(边缘口收到 BPDU 自动 err-down) | stp bpdu-protection |
| 23 | stp edged-port | 端口设为边缘端口(接终端,不参与 STP) | stp edged-port |
| 24 | stp mode mstp | 配 MSTP 域与实例 | stp mode mstp |
| 25 | stp root primary | 设本机为根桥(会改全网拓扑,慎用) | stp root primary |
| 26 | vlan {vlan_id} | 建 Vlan-interface 并配 IP 网关 | interface Vlan-interface 10 |
| 27 | ip address {ip_addr} {mask} | 建 Loopback 并配地址 | ip address 1.1.1.1 32 |
| 28 | arp static {ip_addr} {mac} | 配置静态 ARP 绑定 | arp static 192.168.1.1 0000-0000-0001 |
| 29 | ip route-static 0.0.0.0 0 {next_hop} | 配置默认路由 | ip route-static 0.0.0.0 0 192.168.1.254 |
| 30 | ip route-static {dest_net} {dest_mask} {next_hop} | 配置静态路由 | ip route-static 10.0.0.0 255.0.0.0 192.168.1.254 |
| 31 | undo ip route-static {dest_net} {dest_mask} {next_hop} | 删除静态路由 | undo ip route-static 10.0.0.0 255.0.0.0 |
| 32 | ospf {process_id} router-id {router_id} | OSPF 进程、router-id 与 area 宣告 | ospf 1 router-id 1.1.1.1 |
| 33 | ip address dhcp-alloc | 三层接口改为 DHCP 客户端 | ip address dhcp-alloc |
| 34 | dhcp enable | 开启 DHCP 服务 | dhcp enable |
| 35 | ip pool {pool_name} | 建地址池并向客户端下发 DNS | ip pool vlan10 |
| 36 | dhcp select interface | 用接口地址池自动分配 IP | dhcp select interface |
| 37 | display ip interface brief | 查看三层接口 IP 状态 | display ip interface brief |
| 38 | dialer-group 1 rule ip permit | WAN 口 PPPoE 拨号上网 | dialer-group 1 rule ip permit |
| 39 | display irf | 查看 IRF 堆叠状态 | display irf |
第 3 页 · ACL 安全与配置核对
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 40 | acl number {acl_num} | 创建 ACL | acl number 3000 |
| 41 | acl number {acl_num} | 在 ACL 里放行源网段 | acl number 2000 |
| 42 | acl number {acl_num} | 出方向接口做 NAT,转换源网段 | acl number 2000 |
| 43 | packet-filter {acl_num} inbound | ACL 绑定到端口入方向 | packet-filter 3000 inbound |
| 44 | vrrp vrid {vrid} virtual-ip {vip} | 配 VRRP 备份组与优先级 | vrrp vrid 1 virtual-ip 192.168.1.1 |
| 45 | display vrrp | 查看 VRRP 状态 | display vrrp |
| 46 | ntp-service unicast-server {server_ip} | 配置 NTP 服务器 | ntp-service unicast-server 10.1.1.1 |
| 47 | snmp-agent community read {community} | 配置 SNMP 只读团体名 | snmp-agent community read public |
| 48 | poe enable | 端口开启 PoE 供电 | poe enable |
| 49 | mirroring-group 1 local | 端口流量镜像 | mirroring-group 1 local |
| 50 | stp mode {mode} | 生成树模式设为 rstp / mstp | stp mode rstp |
| 51 | undo acl number {acl_num} | 删除 ACL(端口过滤一并失效) | undo acl number 3000 |
| 52 | acl number {acl_num} | 删除 ACL 内指定规则 | acl number 3000 |
| 53 | undo mirroring-group 1 | 撤销端口镜像组 | undo mirroring-group 1 |
| 54 | undo nat outbound {acl_num} | 撤销出接口 NAT | undo nat outbound 2000 |
| 55 | undo ntp-service unicast-server {server_ip} | 删除 NTP 服务器 | undo ntp-service unicast-server 10.1.1.1 |
| 56 | undo snmp-agent community read {community} | 删除 SNMP 只读团体名 | undo snmp-agent community read public |
第 4 页 · 诊断与维护
| 序号 | 命令 | 用途 | 示例 |
|---|---|---|---|
| 57 | display ip pool | 查看 DHCP 地址池的使用情况 | display ip pool |
| 58 | display interface {port} | 端口详细状态(速率/双工/错包) | display interface GigabitEthernet1/0/1 |
| 59 | display interface {port} | include error | 只看端口的错包统计 | display interface GigabitEthernet1/0/1 | include error |
| 60 | display mac-address interface {port} | 看端口学到了哪些 MAC | display mac-address interface GigabitEthernet1/0/1 |
| 61 | display cpu-usage | 看设备 CPU 占用 | display cpu-usage |
| 62 | display memory | 看设备内存占用 | display memory |
| 63 | display logbuffer | 看设备日志缓冲区 | display logbuffer |
| 64 | display port vlan | 看每个端口属于哪个 VLAN | display port vlan |
| 65 | display ospf peer brief | 查看 OSPF 邻居状态 | display ospf peer brief |
| 66 | display nat session | 查看 NAT 转换(会话)表 | display nat session |
| 67 | display ip routing-table | 查看路由表 | display ip routing-table |
| 68 | display stp brief | 查看生成树状态 | display stp brief |
| 69 | display current-configuration | 查看当前生效配置 | display current-configuration |
| 70 | display interface brief | 查看所有端口简要状态 | display interface brief |
| 71 | display lldp neighbor brief | 查看 LLDP 邻居 | display lldp neighbor brief |
| 72 | display mac-address | 查看 MAC 地址表 | display mac-address |
| 73 | display version | 查看设备型号与版本 | display version |
| 74 | display vlan | 查看所有 VLAN 及成员端口 | display vlan |
| 75 | display link-aggregation verbose | 查看链路聚合状态 | display link-aggregation verbose |
| 76 | display pppoe-client session summary | 查看 PPPoE 拨号会话状态 | display pppoe-client session summary |
> 本章速查表共 76 条命令。