华为交换机登录配置:Console 与 Telnet 实战 - 夜莺博客

华为交换机登录配置:Console 与 Telnet 实战

新到货的华为交换机第一件事就是通过 Console 口完成初始配置,很多运维新手卡在终端仿真软件参数、本地认证配置和 Telnet 远程维护这几步上。本文基于华为官方《交换机登录的典型配置》案例(适用 S300/S500/S2700/S3700/S5700/S6700/S7700/S7900/S9700 系列),完整演示从 Console 接线到 Telnet 远程登录的全过程,命令可直接照抄。

通过 Console 口登录交换机

Console 口登录是交换机最基本、最可靠的登录方式,也是 Telnet、STelnet 等远程登录方式的基础。用 Console 线缆连接 PC 串口与交换机 Console 口(笔记本需 USB 转串口线),打开终端仿真软件,通信参数必须与交换机缺省值一致:传输速率 9600bit/s、数据位 8、停止位 1、无校验、无流控。双主控板设备连接任意主控板的 Console 口均可登录。

配置交换机基本信息

登录后首先设置日期、时间、时区与设备名称,方便后续日志与运维管理:

<Huawei> system-view
[Huawei] clock timezone BJ add 08:00:00
[Huawei] sysname SW-CORE-01
[SW-CORE-01] quit
<SW-CORE-01> clock datetime 09:00:00 2026-08-29

配置 Console 用户界面本地认证

缺省情况下 Console 口登录不需要认证,必须配置本地认证防止未授权访问:

<SW-CORE-01> system-view
[SW-CORE-01] user-interface console 0
[SW-CORE-01-ui-console0] authentication-mode password
[SW-CORE-01-ui-console0] set authentication password cipher Huawei@2026
[SW-CORE-01-ui-console0] quit

配置管理 IP 与 Telnet 远程维护

远程维护需要管理 VLAN 的 IP 地址和 Telnet 服务,并用 ACL 限制可登录的管理员网段:

[SW-CORE-01] vlan 10
[SW-CORE-01-vlan10] quit
[SW-CORE-01] interface vlanif 10
[SW-CORE-01-Vlanif10] ip address 192.168.10.1 255.255.255.0
[SW-CORE-01-Vlanif10] quit
[SW-CORE-01] telnet server enable
[SW-CORE-01] acl number 2000
[SW-CORE-01-acl-basic-2000] rule 5 permit source 192.168.10.0 0.0.0.255
[SW-CORE-01-acl-basic-2000] quit
[SW-CORE-01] user-interface vty 0 4
[SW-CORE-01-ui-vty0-4] authentication-mode password
[SW-CORE-01-ui-vty0-4] set authentication password cipher Admin@2026
[SW-CORE-01-ui-vty0-4] acl 2000 inbound
[SW-CORE-01-ui-vty0-4] quit
[SW-CORE-01] save

验证与排错要点

配置完成后用 display current-configuration | include user-interface 检查认证配置,用 display acl 2000 确认 ACL 规则。Telnet 连不上时依次排查:管理 VLAN 是否配置 IP、telnet server enable 是否开启、VTY 认证是否配置、ACL 是否放行了源地址。生产环境强烈建议改用 STelnet(SSH)加密登录,配合本地用户或 RADIUS 认证。更多华为命令参考 华为 VRP 常用配置与排障命令大全,VLAN 划分实战见 华为交换机配置宝典

相关阅读:华为 CE 交换机配置回滚

原文链接:https://support.huawei.com/enterprise/zh/doc/EDOC1000069491/176653a6