vlan-config
Skill2 starsChanged 3 months agoMITView on GitHub
This skill should be used when the user asks to configure or troubleshoot VLANs on Huawei CloudEngine / S series switches. Covers VLAN creation, access/trunk/hybrid port modes, VLANIF Layer-3 inter-VLAN routing, voice VLAN, management VLAN, VLAN isolation (Layer-2/3), and VLAN tag manipulation. Applicable platforms S/CE switches (V200R011C10+/V200R022C00+) as primary scope; USG firewalls (V500R005C20+/V600R007C20+) only use VLAN in transparent mode or policy filtering.
In this repository16 other files it gives its agents.
- aaa-auth-configSkill
- attack-defenseSkill
- bgp-configSkill
- ha-hrpSkill
- health-checkSkill
- interface-configSkill
- ipsec-vpnSkill
- mirrorSkill
- nat-configSkill
- ospf-configSkill
- security-policySkill
- ssl-vpnSkill
- stack-istackSkill
- static-routeSkill
- vrrpSkill
- wlan-ac-configSkill
The file
Files
华为交换机 VLAN 配置技能 (vlan-config)
适用平台 S1720/S2700/S5700/S6720 V200R011C10+ | CloudEngine 5800-9800 V200R022C00+ 文档来源 华为 S 系列与 CloudEngine 系列产品文档 (dc_cfg_vlan_*)
VLAN 是交换机最基础也是最高频的配置 划分广播域 隔离用户 简化网络管理
触发场景
- 新建 VLAN 划分网段
- 配置 Access/Trunk/Hybrid 接口
- 配置 VLANIF 实现 VLAN 间互访
- 终端 PC 跨 VLAN 不通
- 配置 voice VLAN(语音 IP 电话)
- 管理 VLAN(telnet/SSH 登录用)
- VLAN 内/间隔离
- Trunk 链路两端不通
- 配置 Super-VLAN / MUX-VLAN
接口类型对比(最常错点)
| 类型 | 用途 | 收报文 | 发报文 |
| Access | 接终端 PC/打印机 | 收 untag 打 PVID | 剥 PVID 后 untag 出 |
| Trunk | 交换机互联 | 收 tag 透传 收 untag 打 PVID | 等于 PVID 时剥 tag 出 其他 tag 出 |
| Hybrid | 混合(兼容场景) | 灵活控制 tagged/untagged | 可指定哪些 VLAN tagged 哪些 untagged |
记忆口诀:Access 接终端 Trunk 接交换机 Hybrid 当救火
配置六步走
1 创建 VLAN
system-view
vlan batch 10 20 30 # 批量创建
vlan 10 # 单个创建并进入
description Sales # 描述
quit2 接口配 Access(接终端)
interface GigabitEthernet 0/0/1
port link-type access
port default vlan 103 接口配 Trunk(交换机互联)
interface GigabitEthernet 0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20 30 # 放通哪些 VLAN
port trunk pvid vlan 1 # PVID 默认 1 不动也行⚠️ 不要写
port trunk allow-pass vlan all除非真的要全放通 容易引入广播风暴
4 接口配 Hybrid(灵活控制)
interface GigabitEthernet 0/0/2
port link-type hybrid
port hybrid pvid vlan 10
port hybrid untagged vlan 10 20 # 这些 VLAN 出去时剥 tag
port hybrid tagged vlan 30 # 这个 VLAN 出去保留 tag5 VLANIF 三层互访
interface Vlanif 10
ip address 10.10.10.1 24
interface Vlanif 20
ip address 10.10.20.1 24终端网关指向 VLANIF 的 IP 即可实现 VLAN 间路由
6 验证
display vlan
display vlan summary
display port vlan
display interface Vlanif 10常用命令速查
VLAN 管理
vlan batch <start> [ to <end> ] # 批量创建
display vlan
display vlan <vid>
display vlan summary接口模式
port link-type { access | trunk | hybrid }
port default vlan <vid> # access
port trunk allow-pass vlan { <list> | all }
port trunk pvid vlan <vid>
port hybrid pvid vlan <vid>
port hybrid untagged vlan <list>
port hybrid tagged vlan <list>VLANIF
interface Vlanif <vid>
ip address <ip> <mask>
description <text>语音 VLAN
voice-vlan mac-address <mac> mask <mask>
interface <if>
voice-vlan <vid> enable
voice-vlan mode { auto | manual }管理 VLAN
management-vlan <vid> # 默认 1 改成专用 VLAN 提升安全隔离
# 二层隔离(端口隔离 同 VLAN 内不通)
port-isolate enable group <group-id>
# 三层隔离(VLAN 间禁路由)
traffic-filter inbound acl <num>完整范式 终端 VLAN 划分 + 三层互访
需求:销售(VLAN10)与研发(VLAN20)分别接入 各自网段 通过交换机三层互通
system-view
vlan batch 10 20
# 接终端
interface GigabitEthernet 0/0/1
port link-type access
port default vlan 10
quit
interface GigabitEthernet 0/0/2
port link-type access
port default vlan 20
quit
# VLANIF 网关
interface Vlanif 10
ip address 192.168.10.1 24
quit
interface Vlanif 20
ip address 192.168.20.1 24
quit
# 接上联交换机(如有)
interface GigabitEthernet 0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20
quit常见陷阱
- Trunk 两端 PVID 不一致 → VLAN 1 的流量异常
- Trunk 没把对应 VLAN 加 allow-pass → 跨交换机 VLAN 不通
port trunk allow-pass vlan all→ 引入未规划 VLAN 广播- 终端 PC IP 网段与 VLANIF 不一致 → 网关不通
- 管理 VLAN 改了但忘了在管理口加入 → 自己锁外面
- VLANIF 接口 admin down → display interface 看 protocol 状态
- 没有任何端口属于该 VLAN → VLANIF 也起不来
排查流程
跨 VLAN 不通
|
├─ 同 VLAN 内不通 → 看接口 PVID/access vlan 是否对
├─ 跨交换机不通 → 看 Trunk allow-pass
└─ 跨 VLAN 不通 → 看 VLANIF up 没 PC 网关对不对相关文件
- references/vlan-commands.md 完整命令速查
- references/vlan-troubleshooting.md 故障排查
⚠️ 防火墙 VLAN 与交换机的差异
USG 防火墙的 VLAN 用法与交换机完全不同,不要混用本技能命令到防火墙:
交换机 VLAN(本技能默认描述)
- 划分广播域,三层互通靠 VLANIF
- 经典命令:
vlan batch / port link-type / port trunk allow-pass / interface Vlanif X - VLAN 间路由:VLANIF + ip address
防火墙 VLAN(仅以下两种场景)
- 透明模式(二层透传):防火墙工作在二层,作为 VLAN 报文转发设备
firewall transparent-mode enable firewall transparent inside-vlan inspect enable # QinQ 内层 VLAN 检测 - 安全策略 VLAN 过滤:基于 VLAN ID 控制策略匹配
security-policy rule name vlan_filter vlan-id 100 action permit
关键差异点
| 项 | 交换机 | 防火墙 |
| VLAN 主要用途 | 划广播域 + 三层互通 | 透明转发 / 策略过滤 |
| VLANIF 接口 | ✅ 三层网关 | ❌ 无(防火墙三层走物理接口) |
| port link-type | ✅ 接入/Trunk/Hybrid | ❌(仅透明模式下间接支持) |
| 跨 VLAN 路由 | VLANIF + 路由 | 不在防火墙做,由路由器/三层交换机做 |
CE 系列 vs S 系列差异
- CE 命令完全一致(vlan / port link-type / Vlanif)
- CE 配置后需
commit提交(二阶段提交模型) - CE 进入 VLAN 视图后可用
name <vlan-name>命名,命名后系统视图可用vlan vlan-name <name>直接进入
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

