华为交换机常用命令
            
            
                基础配置命令
| 命令 | 功能 | 示例 | 
| system-view | 进入系统视图,是进行配置的基础。 | <Huawei> system-view | 
| sysname <hostname> | 设置交换机的主机名,便于识别。 | [Huawei] sysname Switch1 | 
| quit | 退出当前视图。 | [Switch1] quit | 
| return | 直接返回用户视图。 | [Switch1] return | 
VLAN配置命令
| 命令 | 功能 | 示例 | 
| vlan <vlan-id> | 创建一个新的VLAN。 | [Huawei] vlan 10 | 
| port default vlan <vlan-id> | 将物理接口加入到指定VLAN中。 | [Huawei-GigabitEthernet0/0/1] port default vlan 10 | 
| port link-type access | 设置端口为Access模式,用于接入终端设备。 | [Huawei-GigabitEthernet0/0/1] port link-type access | 
| port link-type trunk | 设置端口为Trunk模式,允许多个VLAN通过。 | [Huawei-GigabitEthernet0/0/1] port link-type trunk | 
接口配置命令
| 命令 | 功能 | 示例 | 
| interface GigabitEthernet <slot>/<port> | 进入指定物理接口的配置视图。 | [Huawei] interface GigabitEthernet 0/0/1 | 
| speed <speed-value> | 配置端口速率,如10M、100M、1G等。 | [Huawei-GigabitEthernet0/0/1] speed 1000 | 
| duplex full | 设置端口为全双工模式。 | [Huawei-GigabitEthernet0/0/1] duplex full | 
| shutdown/undo shutdown | 禁用或启用接口。 | [Huawei-GigabitEthernet0/0/1] shutdown | 
IP与路由配置命令
| 命令 | 功能 | 示例 | 
| interface Vlanif <vlan-id> | 进入VLAN接口配置视图,用于配置管理IP。 | [Huawei] interface Vlanif 10 | 
| ip address <ip-address> <subnet-mask> | 配置VLAN接口的IP地址。 | [Huawei-Vlanif10] ip address 192.168.10.1 255.255.255.0 | 
| ip route-static <destination> <mask> <next-hop> | 配置静态路由。 | [Huawei] ip route-static 0.0.0.0 0.0.0.0 192.168.1.254 | 
远程管理配置命令
| 命令 | 功能 | 示例 | 
| telnet server enable | 开启Telnet服务。 | [Switch1] telnet server enable | 
| user-interface vty 0 4 | 配置VTY线路(0-4为默认范围)。 | [Switch1] user-interface vty 0 4 | 
| local-user <username> password cipher <password> | 创建本地用户并设置密码。 | [Switch1] local-user admin password cipher Admin@123 | 
| local-user <username> privilege level 15 | 设置用户权限级别。 | [Switch1] local-user admin privilege level 15 | 
查看与排障命令
| 命令 | 功能 | 示例 | 
| display current-configuration | 查看当前运行配置。 | <Switch1> display current-configuration | 
| display vlan | 查看VLAN配置及端口划分情况。 | <Switch1> display vlan | 
| display interface brief | 查看所有端口的基本状态。 | <Switch1> display interface brief | 
| display cpu-usage | 查看CPU利用率。 | <Switch1> display cpu-usage | 
| ping <ip-address> | 测试网络连通性。 | <Switch1> ping 192.168.1.1 | 
保存与恢复配置命令
| 命令 | 功能 | 示例 | 
| save | 保存当前配置到Flash。 | <Switch1> save | 
| reset saved-configuration | 清空已保存的配置。 | <Switch1> reset saved-configuration | 
| reboot | 重启交换机。 | <Switch1> reboot | 
相关问题与解答
问题1:如何批量将多个端口加入同一个VLAN?
解答:可以使用port-group命令创建端口组,然后将端口组中的端口一次性加入VLAN。

[Switch1] port-group 1
[Switch1-port-group1] group-member GigabitEthernet 1/0/1 to 1/0/20
[Switch1-port-group1] port link-type access
[Switch1-port-group1] port default vlan 200
问题2:如何配置交换机的管理IP以便远程登录?
解答:可以通过配置VLAN接口的IP地址来实现。

[Switch1] interface Vlanif 10
[Switch1-Vlanif10] ip address 192.168.1.1 255.255.255.0
[Switch1-Vlanif10] quit
[Switch1] ip route-static 0.0.0.0 0.0.0.0 192.168.1.