网络

华为交换机初始配置

· 896 字 · 约 2 分钟

以下是一份华为交换机初始化配置的基本步骤指南,适用于常见的园区网络环境。请根据实际需求调整参数(如 IP 地址、VLAN 号等):

华为交换机初始化配置步骤

一、连接设备

使用 Console 线连接交换机 Console 口 使用终端软件(如 PuTTY/Xshell)连接:

  • 波特率:9600
  • 数据位:8
  • 停止位:1
  • 无校验

二、基础配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 进入系统视图
system-view

# 设置设备名称
sysname SW-Office-01

# 关闭信息中心(可选,减少日志干扰)
info-center disable

# 设置时区与时间
clock timezone UTC+08:00 add 08:00:00
clock datetime 12:00:00 2024-01-01

# 配置管理VLAN(示例:VLAN 1)
vlan 1
quit

# 配置管理IP
interface Vlanif 1
 ip address 192.168.1.1 255.255.255.0
 quit

# 配置默认网关(若需要)
ip route-static 0.0.0.0 0.0.0.0 192.168.1.254

三、安全加固

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 启用SSH服务
stelnet server enable
ssh user admin
ssh user admin authentication-type password
ssh user admin service-type stelnet

# 配置本地用户(示例用户:admin)
aaa
 local-user admin password irreversible-cipher Huawei@1234
 local-user admin privilege level 15
 local-user admin service-type ssh
 quit

# 关闭HTTP服务(推荐关闭)
undo http server enable

# 开启密码复杂度检查
password complexity enable

# 配置Console口超时(5分钟无操作自动断开)
user-interface console 0
 idle-timeout 5 0
 quit

四、远程管理配置

1
2
3
4
5
6
7
# 配置SSH访问
rsa local-key-pair create  # 生成RSA密钥
ssh authentication-type default password
ssh client first-time enable

# 开启STelnet服务
stelnet server enable

五、端口基础配置

1
2
3
4
5
6
7
8
# 批量配置端口描述(示例:1-24口)
interface range GigabitEthernet 0/0/1 to 0/0/24
 description User_Access_Port
 undo shutdown
 port link-type access  # 或设为 trunk/hybrid 根据需求
 port default vlan 10   # 根据实际VLAN设计修改
 stp edged-port enable  # 启用边缘端口(防止STP阻塞)
 quit

六、端口安全(可选)

1
2
3
4
5
6
## 启用端口安全(限制MAC数量)
interface GigabitEthernet 0/0/1
 port-security enable
 port-security max-mac-num 5
 port-security protect-action shutdown
 quit

七、保存配置

1
2
3
4
5
6
## 返回用户视图
quit

## 保存配置
save
y  # 确认保存

八、验证配置

1
2
3
4
5
6
7
8
9
连通性测试:
ping 192.168.1.254  # 测试网关可达性

远程登录测试:
ssh admin@192.168.1.1  # 使用SSH客户端登录

配置检查:
display current-configuration  # 查看当前配置
display interface brief        # 检查端口状态

高级配置(可选)

  1. SNMP 监控:配置 SNMPv3 团体字和权限
  2. LLDP 协议:lldp enable(用于拓扑发现)
  3. 端口聚合:使用 eth-trunk 配置链路聚合
  4. QoS 策略:配置流量限速或优先级
  5. 动态路由协议:如 OSPF/RIP(仅三层交换机支持)

注意事项

  1. 生产环境中建议使用非默认 VLAN 作为管理 VLAN
  2. 特权密码建议定期更换
  3. 首次配置后建议备份配置文件
  4. 不同型号/VRP 版本可能存在命令差异,请以官方文档为准