华为 S5700 交换机划分 VLAN:单口与批量配置 - 夜莺博客

华为 S5700 交换机划分 VLAN:单口与批量配置

VLAN 划分是华为交换机配置中最基础也最高频的操作,S5700 作为园区网主力机型,几乎每天都要和它打交道。本文用最直白的方式演示 S5700 上划分 VLAN 的完整流程:创建 VLAN、给 VLAN 配 IP、单个端口接入、以及用端口组批量把多个端口一次性划入 VLAN,并给出验证和保存命令。

基础准备:进入系统视图

<Huawei> system-view
Enter system view, return user view with Ctrl+Z.
[Huawei] sysname center_switch

先给交换机起个有意义的名字,便于多台设备管理时区分。

创建 VLAN 并配置 VLANIF 接口 IP

[center_switch] vlan 40
[center_switch-vlan40] quit
[center_switch] interface Vlanif 40
[center_switch-Vlanif40] ip address 10.10.40.1 255.255.255.0
[center_switch-Vlanif40] quit

Vlanif 接口是三层的,配了 IP 后该 VLAN 就具备网关能力,终端可以跨 VLAN 三层互通。

将单个端口加入 VLAN

[center_switch] interface GigabitEthernet 0/0/24
[center_switch-GigabitEthernet0/0/24] port link-type access
[center_switch-GigabitEthernet0/0/24] port default vlan 40

接入终端的口用 access 类型,port default vlan 40 把端口划入 VLAN 40。注意华为语法是 port default vlan,不要和 Cisco 的 switchport access vlan 混淆。

批量将一组端口加入 VLAN(端口组)

[center_switch] vlan 42
[center_switch-vlan42] quit
[center_switch] interface Vlanif 42
[center_switch-Vlanif42] ip address 10.10.42.1 255.255.255.0
[center_switch-Vlanif42] quit
[center_switch] port-group port1to8forvlan42
[center_switch-port-group-port1to8forvlan42] group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/8
[center_switch-port-group-port1to8forvlan42] port link-type access
[center_switch-port-group-port1to8forvlan42] port default vlan 42

端口组(port-group)是 S5700 批量配置的利器:先用 group-member ... to ... 指定 1-8 号端口,后续所有命令自动应用到整组端口,比逐个端口配置高效得多。

验证与保存

[center_switch] display vlan
[center_switch] save

display vlan 确认 VLAN 及端口成员关系,save 保存配置防止重启丢失。其它常用验证命令:display current-configuration 查看运行配置、display interfaces brief 查看接口状态。更多华为配置命令见 华为交换机配置宝典VRP 常用配置与排障命令大全,误操作回滚见 华为 CE 交换机配置回滚

原文链接:https://www.jb51.net/network/227460.html