配置实战:H3C 交换机基础配置模板

适用场景

新交换机上架后,按此模板完成基础配置。

完整配置

# 1. 系统基础
system-view
sysname SW-Core-01
clock timezone Beijing add 08:00:00

# 2. 启用必要服务
telnet server enable
ssh server enable

# 3. 管理 IP(VLAN 1 上,或新建管理 VLAN)
vlan 100
 name Management
interface Vlan-interface 100
 ip address 10.0.100.1 255.255.255.0
 quit

# 4. 默认网关
ip route-static 0.0.0.0 0.0.0.0 10.0.100.254

# 5. 创建业务 VLAN
vlan 10
 description Sales
vlan 20
 description Engineering
vlan 30
 description Finance

# 6. Trunk 端口配置(下联汇聚)
interface GigabitEthernet1/0/1
 port link-type trunk
 port trunk permit vlan 1 10 20 30 100
 port trunk pvid vlan 1
 quit

# 7. Access 端口配置(接 PC)
interface GigabitEthernet1/0/2
 port access vlan 10
 quit

# 8. 本地用户(telnet/ssh 登录)
local-user admin class manage
 password simple YourP@ssw0rd
 service-type telnet ssh terminal
 authorization-attribute user-role network-admin
 quit

# 9. VTY 认证
line vty 0 15
 authentication-mode scheme
 user-role network-admin
 quit

# 10. 保存
save force

✅ 配置后验证

display version
display vlan brief
display ip interface brief
display current-configuration

💡 经验

  • 密码建议用 hash 而非 simple
  • authorization-attribute user-role 一定要给,默认权限不够
  • 改完配置先 display 验证,再 save
  • 远程配置前保留 Console 登录窗口,避免配置错误断连

关注公众号「网英的日常」,获取更多配置模板。