交换机开箱配置清单
场景
新设备上架。业务配置(VLAN、Trunk)各有各的文档,但「管理面」这一套每次都大同小异:改名、管理地址、SSH、账号、时间、监控、日志、关掉不用的服务。这篇就是那张固定的清单,照着敲完再交给业务配置。
前置条件
- 串口线(Console)或者带外管理已就绪
- 规划好管理 VLAN(例:
99)和管理网段(例:10.99.1.0/24) - 知道网关地址(例:
10.99.1.1) - 有 NTP 服务器和 SNMP 采集端地址
- 记录设备型号和当前版本(
display version),后面选命令要看版本
配置
华为 S 系列(VRP V5 写法):
system-view
sysname SW-1F-01
# 管理 VLAN 和地址
vlan 99
quit
interface Vlanif99
ip address 10.99.1.11 255.255.255.0
quit
interface GigabitEthernet0/0/24
port link-type trunk
port trunk allow-pass vlan 99
quit
ip route-static 0.0.0.0 0.0.0.0 10.99.1.1
# SSH
rsa local-key-pair create
stelnet server enable
aaa
local-user admin password irreversible-cipher 换成你的强密码
local-user admin privilege level 15
local-user admin service-type ssh
quit
user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
quit
ssh user admin authentication-type password
ssh user admin service-type stelnet
# 时间
ntp-service enable
ntp-service unicast-server 10.99.1.1
# 监控
snmp-agent
snmp-agent sys-info version v2c
snmp-agent community read cipher 换成你的团体名
snmp-agent target-host trap-hostname nms address 10.99.1.100 udp-port 162
snmp-agent trap enable
# 日志
info-center enable
info-center loghost 10.99.1.100
# 关掉不用的服务
undo telnet server enable
undo http server enable
undo http secure-server enable
save
H3C(Comware V7 写法,V5 见「坑」):
system-view
sysname SW-1F-01
vlan 99
quit
interface Vlan-interface99
ip address 10.99.1.11 24
quit
interface GigabitEthernet1/0/24
port link-type trunk
port trunk permit vlan 99
quit
ip route-static 0.0.0.0 0 10.99.1.1
public-key local create rsa
ssh server enable
local-user admin class manage
password simple 换成你的强密码
service-type ssh
authorization-attribute user-role network-admin
quit
line vty 0 4
authentication-mode scheme
protocol inbound ssh
quit
ntp-service enable
ntp-service unicast-server 10.99.1.1
snmp-agent
snmp-agent sys-info version v2c
snmp-agent community read 换成你的团体名
snmp-agent target-host trap address udp-domain 10.99.1.100 params securityname 团体名 v2c
info-center enable
info-center loghost 10.99.1.100
undo telnet server enable
undo ip http enable
save force
验证
display clock # 时间和时区对了没
display ntp-service status # 同步上了没
display ssh server status # SSH 开着
display users # 现在谁在线
display snmp-agent community # 团体名
display ip interface brief # 管理地址
display vlan # 管理 VLAN 有成员口
ping 10.99.1.1 # 网关通
四项必须过:时间对、SSH 能登、管理地址 ping 得通、SNMP 采集端能看到设备。
回滚
新设备还没接业务,回滚就是恢复出厂:
reset saved-configuration # 华为:清空下次启动配置
reboot
reset saved-configuration # H3C 同名命令
reboot
提前接进网的话,把 Vlanif99 和上联 Trunk 撤掉即可断开管理面,不影响其他设备。
坑
版本不同,账号写法不一样
H3C V7 要 local-user xxx class manage 加 authorization-attribute user-role network-admin;
V5 是 local-user xxx 加 authorization-attribute level 3。
华为 V5 用 privilege level 15,V8(CE 系列)改用 local-user xxx privilege level 15 + service-type ssh,细节有出入,按设备提示补全。
- 先配管理面再做业务。反过来一旦 Trunk 配错,人就进不去了。
undo http server enable在老版本上可能没有这条,报错就跳过,不影响 SSH。- SNMP v2c 是明文团体名。只在管理网用,别开在业务口能到的地方。
save之前断电,配置全丢。华为的save会问 y/n,H3C V5 要save force才不弹确认。- RSA 密钥生成在部分低版本上要几十秒,别以为卡死了。
- 管理 VLAN 的网关如果不在本机,记得配默认路由,否则只能同网段访问。
- 时区:华为默认可能不是 UTC+8,用
clock timezone BJ add 08:00:00设好再对时,不然日志时间对不上。