# VXLAN: 隧道 vxlan0 上 VNI 不匹配，期望 100，从 10.0.0.2 收到 200

- **ID:** `networking/vxlan-vni-mismatch`
- **领域:** networking
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

VXLAN VNI 不匹配发生在 VXLAN 隧道的两个端点配置了不同的虚拟网络标识符时，导致数据包被丢弃或错误路由。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Linux kernel 5.10+ | active | — | — |
| Open vSwitch 2.17+ | active | — | — |
| Cisco IOS XE 17.3+ | active | — | — |

## 解决方案

1. ```
   Check the VXLAN configuration on both endpoints using 'ip -d link show vxlan0' and update the VNI: ip link set vxlan0 type vxlan id 100
   ```
2. ```
   If using Open vSwitch, verify the VNI in the bridge configuration: ovs-vsctl list interface vxlan0 | grep vni, then set the correct value: ovs-vsctl set interface vxlan0 options:vni=100
   ```
3. ```
   Temporarily set the VXLAN interface to learning mode to diagnose the mismatch: ip link set vxlan0 type vxlan learning
   ```

## 无效尝试

- **** — 重启 VXLAN 接口或整个主机无法修复配置不匹配；两端的 VNI 值必须对齐。 (95% 失败率)
- **** — 增加 VXLAN 接口的 MTU 可能有助于分片，但无法解决 VNI 不匹配问题，这是一个逻辑标识符问题。 (90% 失败率)
- **** — 禁用底层网络上的防火墙规则可能允许 VXLAN 数据包通过，但 VNI 不匹配仍会导致隧道端点丢弃数据包。 (85% 失败率)
