hbugs001 发表于 2026-11-1 01:36:23

实验案例:Cisco IOL XE 跑通 VXLAN EVPN

<h1>实验案例:Cisco IOL XE 跑通 VXLAN EVPN(2 spine + 4 leaf + 8 主机,含 10 条流量过滤器)</h1>
<blockquote>
<p>用免费的 Cisco IOL 镜像搭一套完整的 VXLAN EVPN fabric:2 台 spine 做 EVPN route reflector,4 台 leaf 做 VTEP,8 台主机分属 4 个 VLAN;每台 leaf 都有全部 4 个 SVI,用<strong>同一 IP + 同一 MAC</strong> 做分布式 anycast 网关,<strong>不配 L3 VNI</strong> 也能跨子网。完整启动配置与 IaC 拓扑放在附件包,正文只留核心配置、验收判据和踩坑清单。</p>
<p>实测环境:EVE-NG + eve-iac agent 0.9.1;Cisco IOS-XE 17.18.2(IOL,<code>l2-iol-xe-17-18-02.bin</code>);VPCS 1.3 (0.8.1)。</p>
</blockquote>
<blockquote>
<p>???? 完整预配与 IaC 文件见 §10.1 附件包;第 5 节只列核心行,<strong>不要直接拿片段去粘贴</strong>。</p>
</blockquote>
<blockquote>
<p>运行态:三条 ping 同时跑,<code>VXLAN-VNI-10010</code>(72)与 <code>VXLAN-VNI-10030</code>(76)同时点亮,<code>ICMP-Request/Reply</code> 各 112 一一对应;<strong>单独跑一组时只有对应的那个 VNI 亮</strong>。ARP 三项为 0 是正常的——ARP 表已填满,不再发包。</p>
</blockquote>
<p><img src="data/attachment/forum/202611/01/013242nxjqfeyntwo7eeqn.png" alt="vxlan-evpn-xe-topology.png" title="vxlan-evpn-xe-topology.png" /></p>
<p><img src="data/attachment/forum/202611/01/013254imxqqq11k9m5e64m.png" alt="vxlan-evpn-xe-runtime.png" title="vxlan-evpn-xe-runtime.png" /><br />
<a href="forum.php?mod=attachment&amp;aid=3631" title="attachment"><img src="/source/plugin/zhanmishu_markdown/template/editor/images/upload.svg" alt="upload" /> 附件:vxlan-evpn-xe.zip</a></p>
<h2>0. 实测结果</h2>
<table>
<thead>
<tr>
<th>项</th>
<th>实测结果</th>
</tr>
</thead>
<tbody>
<tr>
<td>Underlay</td>
<td>OSPF area 0,每台 leaf 两个邻居 <code>FULL</code>,/30 点对点链路</td>
</tr>
<tr>
<td>Overlay</td>
<td>iBGP AS 65000,两台 spine 做 RR;每台 leaf 两条 EVPN 会话 <code>Established</code>、<code>PfxRcd &gt; 0</code></td>
</tr>
<tr>
<td>控制面</td>
<td>每台 leaf:<code>show nve vni</code>4 个 <code>Up</code>,<code>show nve peers</code>3 远端 × 4 VNI = 12 个 <code>Up</code></td>
</tr>
<tr>
<td>MAC-IP</td>
<td><code>show l2vpn evpn mac ip</code>每台 leaf 8 条,本地主机指向 <code>Et0/x:vlan</code>,远端主机指向对端 VTEP</td>
</tr>
<tr>
<td>数据面</td>
<td>5 组 ping 全部 5/5;<strong>同 VLAN <code>ttl=64</code>,跨 VLAN <code>ttl=63</code></strong></td>
</tr>
<tr>
<td>可视化</td>
<td>10 条 traffic filter 全部通过 libpcap 编译并部署</td>
</tr>
</tbody>
</table>
<h2>1. 这个实验解决什么</h2>
<p>VXLAN EVPN 的教程大多从“两台交换机、一个 VNI”讲起,看完还是不知道真实 fabric 长什么样;而厂商的完整设计文档一上来就是双租户、对称 IRB、ESI 多归,节点多到没法一次看完。这个案例取中间那一档:</p>
<ul>
<li>6 台 IOL,正好是一台普通 PC 能跑满的规模:2 spine + 4 leaf,underlay 和 overlay 都完整;</li>
<li>4 个 VLAN 分两个区(A 区 10/20、B 区 30/40),能看到“同一个 VLAN 横跨两台 leaf”和“跨 VLAN 要经过网关”两种路径;</li>
<li>刻意不做 L3 VNI:跨子网靠每台 leaf 的 anycast SVI 本地路由,再用目标 VLAN 的 L2 VNI 转发——这是理解“分布式网关到底解决了什么”的最短路径;</li>
<li>10 条流量过滤器把 ARP、ICMP、OSPF、BGP、VXLAN 封装和指定 VNI 在拓扑上实时点亮,还能给出“该不亮就不亮”的反证。</li>
</ul>
<p>跑完这个实验,再回头看 cEOS 那套对称 IRB 双租户,会顺畅很多。</p>
<h2>2. 镜像与规格</h2>
<table>
<thead>
<tr>
<th>节点</th>
<th>角色</th>
<th>EVE 模板</th>
<th>镜像</th>
<th>vCPU / RAM</th>
<th>网口</th>
</tr>
</thead>
<tbody>
<tr>
<td>SPINE1 / SPINE2</td>
<td>EVPN RR(<strong>不是 VTEP</strong>)</td>
<td><code>iol</code></td>
<td><code>l2-iol-xe-17-18-02.bin</code></td>
<td>1 / 1024 MB</td>
<td><code>Ethernet0/0..0/3</code></td>
</tr>
<tr>
<td>LEAF1 … LEAF4</td>
<td>VTEP + 分布式网关</td>
<td><code>iol</code></td>
<td><code>l2-iol-xe-17-18-02.bin</code></td>
<td>1 / 1024 MB</td>
<td><code>Ethernet0/0..0/3</code></td>
</tr>
<tr>
<td>HOST-A1 … HOST-B4</td>
<td>主机</td>
<td><code>vpcs</code></td>
<td>EVE 自带</td>
<td>—</td>
<td><code>eth0</code></td>
</tr>
</tbody>
</table>
<p>注意事项:</p>
<ul>
<li>IOL 的 attributes.ethernet 填 1 就得到 4 个口(Ethernet0/0..0/3),不是“1 个口”——这是 IOL 模板自己的 ×4 规则,和 VyOS 那类按个数计的模板不同。</li>
<li>镜像必须是支持 VXLAN 的 XE 版本:interface nve1 和 l2vpn evpn 两条命令都能进才算数。15.2 的 l2-adventerprisek9-ms 两条都报 % Invalid input。</li>
<li>l2-* 是三层交换机镜像(能交换也能路由),不是纯二层交换机;l3-* 是路由器镜像。本实验 leaf 更贴近三层交换机,选 l2-*。</li>
<li>节点名必须纯 ASCII。中文节点名在 EVE 往返时会丢字,eve-iac 部署报 invalid_native_format 并静默删库。</li>
</ul>
<p>确认镜像没拿错,登录任意一台 IOL 执行 <code>show version</code>,应同时看到 <code>Version 17.18.2</code>、<code>System image file is &quot;unix:/opt/unetlab/addons/iol/bin/l2-iol-xe-17-18-02.bin&quot;</code> 和 <code>4 Ethernet interfaces</code>。</p>
<h2>3. 拓扑与地址</h2>
<p>两台 spine 各用 4 个口接 4 台 leaf;每台 leaf 的 <code>Ethernet0/0</code> / <code>Ethernet0/1</code> 上联两台 spine,<code>Ethernet0/2</code> / <code>Ethernet0/3</code> 接两台主机。</p>
<table>
<thead>
<tr>
<th>#</th>
<th>链路</th>
<th>类型</th>
<th>网段(A 端 / B 端)</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>SPINE1 <code>Et0/0</code>↔ LEAF1 <code>Et0/0</code></td>
<td>路由口</td>
<td><code>10.0.1.0/30</code>(<code>.1</code>/<code>.2</code>)</td>
</tr>
<tr>
<td>2</td>
<td>SPINE1 <code>Et0/1</code>↔ LEAF2 <code>Et0/0</code></td>
<td>路由口</td>
<td><code>10.0.1.4/30</code>(<code>.5</code>/<code>.6</code>)</td>
</tr>
<tr>
<td>3</td>
<td>SPINE1 <code>Et0/2</code>↔ LEAF3 <code>Et0/0</code></td>
<td>路由口</td>
<td><code>10.0.1.8/30</code>(<code>.9</code>/<code>.10</code>)</td>
</tr>
<tr>
<td>4</td>
<td>SPINE1 <code>Et0/3</code>↔ LEAF4 <code>Et0/0</code></td>
<td>路由口</td>
<td><code>10.0.1.12/30</code>(<code>.13</code>/<code>.14</code>)</td>
</tr>
<tr>
<td>5</td>
<td>SPINE2 <code>Et0/0</code>↔ LEAF1 <code>Et0/1</code></td>
<td>路由口</td>
<td><code>10.0.2.0/30</code>(<code>.1</code>/<code>.2</code>)</td>
</tr>
<tr>
<td>6</td>
<td>SPINE2 <code>Et0/1</code>↔ LEAF2 <code>Et0/1</code></td>
<td>路由口</td>
<td><code>10.0.2.4/30</code>(<code>.5</code>/<code>.6</code>)</td>
</tr>
<tr>
<td>7</td>
<td>SPINE2 <code>Et0/2</code>↔ LEAF3 <code>Et0/1</code></td>
<td>路由口</td>
<td><code>10.0.2.8/30</code>(<code>.9</code>/<code>.10</code>)</td>
</tr>
<tr>
<td>8</td>
<td>SPINE2 <code>Et0/3</code>↔ LEAF4 <code>Et0/1</code></td>
<td>路由口</td>
<td><code>10.0.2.12/30</code>(<code>.13</code>/<code>.14</code>)</td>
</tr>
<tr>
<td>9</td>
<td>LEAF1 <code>Et0/2</code>/<code>Et0/3</code>↔ HOST-A1 / A2</td>
<td>access</td>
<td>VLAN 10 / VLAN 20</td>
</tr>
<tr>
<td>10</td>
<td>LEAF2 <code>Et0/2</code>/<code>Et0/3</code>↔ HOST-A3 / A4</td>
<td>access</td>
<td>VLAN 10 / VLAN 20</td>
</tr>
<tr>
<td>11</td>
<td>LEAF3 <code>Et0/2</code>/<code>Et0/3</code>↔ HOST-B1 / B2</td>
<td>access</td>
<td>VLAN 30 / VLAN 40</td>
</tr>
<tr>
<td>12</td>
<td>LEAF4 <code>Et0/2</code>/<code>Et0/3</code>↔ HOST-B3 / B4</td>
<td>access</td>
<td>VLAN 30 / VLAN 40</td>
</tr>
</tbody>
</table>
<p>环回与角色:</p>
<table>
<thead>
<tr>
<th>设备</th>
<th>角色</th>
<th>Loopback0</th>
<th>BGP</th>
</tr>
</thead>
<tbody>
<tr>
<td>SPINE1</td>
<td>EVPN RR</td>
<td><code>10.255.0.1/32</code></td>
<td>AS 65000,<strong>无 <code>nve1</code></strong></td>
</tr>
<tr>
<td>SPINE2</td>
<td>EVPN RR</td>
<td><code>10.255.0.2/32</code></td>
<td>AS 65000,<strong>无 <code>nve1</code></strong></td>
</tr>
<tr>
<td>LEAF1</td>
<td>VTEP</td>
<td><code>10.255.0.11/32</code></td>
<td>AS 65000,与两台 spine 建邻居</td>
</tr>
<tr>
<td>LEAF2</td>
<td>VTEP</td>
<td><code>10.255.0.12/32</code></td>
<td>同上</td>
</tr>
<tr>
<td>LEAF3</td>
<td>VTEP</td>
<td><code>10.255.0.13/32</code></td>
<td>同上</td>
</tr>
<tr>
<td>LEAF4</td>
<td>VTEP</td>
<td><code>10.255.0.14/32</code></td>
<td>同上</td>
</tr>
</tbody>
</table>
<p>VLAN / VNI / 网关:</p>
<table>
<thead>
<tr>
<th>VLAN</th>
<th>名称</th>
<th>VNI</th>
<th>子网</th>
<th>网关(<strong>所有 leaf 相同</strong>)</th>
</tr>
</thead>
<tbody>
<tr>
<td>10</td>
<td>WEB</td>
<td><code>10010</code></td>
<td>10.10.10.0/24</td>
<td><code>10.10.10.1</code>,MAC <code>0000.5e00.0101</code></td>
</tr>
<tr>
<td>20</td>
<td>APP</td>
<td><code>10020</code></td>
<td>10.10.20.0/24</td>
<td><code>10.10.20.1</code>,同 MAC</td>
</tr>
<tr>
<td>30</td>
<td>DB</td>
<td><code>10030</code></td>
<td>10.10.30.0/24</td>
<td><code>10.10.30.1</code>,同 MAC</td>
</tr>
<tr>
<td>40</td>
<td>OPS</td>
<td><code>10040</code></td>
<td>10.10.40.0/24</td>
<td><code>10.10.40.1</code>,同 MAC</td>
</tr>
</tbody>
</table>
<p>主机地址:</p>
<table>
<thead>
<tr>
<th>主机</th>
<th>IP / 24</th>
<th>网关</th>
<th>VLAN</th>
<th>接入</th>
<th>主机</th>
<th>IP / 24</th>
<th>网关</th>
<th>VLAN</th>
<th>接入</th>
</tr>
</thead>
<tbody>
<tr>
<td>HOST-A1</td>
<td>10.10.10.11</td>
<td>.1</td>
<td>10</td>
<td>LEAF1 <code>Et0/2</code></td>
<td>HOST-B1</td>
<td>10.10.30.11</td>
<td>.1</td>
<td>30</td>
<td>LEAF3 <code>Et0/2</code></td>
</tr>
<tr>
<td>HOST-A2</td>
<td>10.10.20.11</td>
<td>.1</td>
<td>20</td>
<td>LEAF1 <code>Et0/3</code></td>
<td>HOST-B2</td>
<td>10.10.40.11</td>
<td>.1</td>
<td>40</td>
<td>LEAF3 <code>Et0/3</code></td>
</tr>
<tr>
<td>HOST-A3</td>
<td>10.10.10.12</td>
<td>.1</td>
<td>10</td>
<td>LEAF2 <code>Et0/2</code></td>
<td>HOST-B3</td>
<td>10.10.30.12</td>
<td>.1</td>
<td>30</td>
<td>LEAF4 <code>Et0/2</code></td>
</tr>
<tr>
<td>HOST-A4</td>
<td>10.10.20.12</td>
<td>.1</td>
<td>20</td>
<td>LEAF2 <code>Et0/3</code></td>
<td>HOST-B4</td>
<td>10.10.40.12</td>
<td>.1</td>
<td>40</td>
<td>LEAF4 <code>Et0/3</code></td>
</tr>
</tbody>
</table>
<blockquote>
<p>EVE 连线界面里的端口显示为 <code>e0/0</code> 这类短名,设备内部是 <code>Ethernet0/0</code>,两者是同一个口。</p>
</blockquote>
<h2>4. 关键设计</h2>
<ul>
<li>spine 只做 RR,不做 VTEP:两台 spine 上没有 nve1,只跑 OSPF 和 BGP EVPN 反射。VTEP 越少,排错路径越短;spine 宕一台,EVPN 路由由另一台继续反射(本实验未做故障收敛测试)。</li>
<li>L2 VNI 必须走 EVI:只配 interface nve1 下的 member vni 会出现“BGP 邻居 Established,但 show bgp l2vpn evpn 全空、PfxRcd = 0”。每个 VLAN 都要有 l2vpn evpn instance <id> vlan-based 和 vlan configuration <vlan> → member evpn-instance。</li>
<li>ingress-replication,不用组播 underlay:l2vpn evpn 全局配 replication-type ingress,每个 VNI 在 nve1 下配 ingress-replication。拓扑上不需要 PIM,省掉一整层变量。</li>
<li>**分布式 anycast 网关:同 IP + 同 MAC + no ip proxy-arp**:4 台 leaf 的 Vlan10 都是 10.10.10.1 和 0000.5e00.0101,主机换 leaf 时 ARP 缓存不失效;no ip proxy-arp 防止某台 leaf 用 anycast MAC 代替远端主机应答,破坏 MAC-IP 学习。</li>
<li>不配 L3 VNI:跨子网由本地 anycast SVI 路由,再用目标 VLAN 的 L2 VNI 转发。代价是每台 leaf 都要有全部 4 个 SVI;收益是没有 VRF、没有对称 IRB,链路只有一条。</li>
<li>用 switchport voice vlan 保活 SVI:每台 leaf 只有 2 个 VLAN 有本地 access 口,另外 2 个 VLAN 在开机时本地没有 up 端口,SVI 会一直是 down;no autostate 拉不起来。把缺失的 VLAN 配成主机口的 voice VLAN,让它本地 active,SVI 就能开机 up,而主机的 untagged 流量仍走 access VLAN。</li>
</ul>
<h2>5. 核心配置(完整预配见附件)</h2>
<p>完整逐字的 14 份配置在附件包里(§10.1)。本节只摘<strong>核心行</strong>说明“这台设备为什么能参与 VXLAN/EVPN”,<strong>不要直接拿片段粘贴</strong>,复现请用附件里的 <code>configs/default/n_X.cfg</code>。</p>
<h3>5.1 SPINE1 / SPINE2(两台同构,只列 SPINE1 的行)</h3>
<pre><code class="language-text">l2vpn evpn
replication-type ingress
router-id Loopback0
!
router bgp 65000
no bgp default ipv4-unicast
address-family l2vpn evpn
neighbor 10.255.0.11 route-reflector-client
neighbor 10.255.0.11 send-community extended
</code></pre>
<p>要点:spine **没有 <code>nve1</code>**,只反射 EVPN 路由。<code>show nve vni</code> 在 spine 上会报错,这是对的。</p>
<h3>5.2 LEAF1 … LEAF4(四台同构,只列 LEAF1 的行)</h3>
<pre><code class="language-text">ip routing
vtp mode transparent
!
vlan configuration 10
member evpn-instance 10 vni 10010
!
l2vpn evpn instance 10 vlan-based
encapsulation vxlan
replication-type ingress
advertise mac enable
!
interface nve1
no shutdown
source-interface Loopback0
host-reachability protocol bgp
member vni 10010
ingress-replication
!
interface Vlan10
no autostate
no ip proxy-arp
mac-address 0000.5e00.0101
ip address 10.10.10.1 255.255.255.0
</code></pre>
<p><code>vlan 20 / 30 / 40</code> 各重复一遍(EVI 号 = VLAN 号,VNI 号见 §3),四台 leaf 的 SVI 地址和 MAC 完全相同。</p>
<h3>5.3 主机口:voice VLAN 保活</h3>
<pre><code class="language-text">interface Ethernet0/2
switchport mode access
switchport access vlan 10
switchport voice vlan 30
spanning-tree portfast
</code></pre>
<p>LEAF1/LEAF2 的主机口补 VLAN 30/40,LEAF3/LEAF4 补 VLAN 10/20。**必须 <code>switchport mode access</code>**:IOL 的 trunk 口不接收 VPCS 的 untagged 流量。</p>
<h3>5.4 VPCS 主机(完整两行)</h3>
<pre><code class="language-text">set pcname HOST-A1
ip 10.10.10.11/24 10.10.10.1
</code></pre>
<p>VPCS 的启动脚本不是 Cisco CLI:主机名要 <code>set pcname NAME</code>,地址行是 <code>ip ADDR/MASK GATEWAY</code>,**<code>ip</code> 行不要加 <code>set</code>**。</p>
<h2>6. 复现步骤</h2>
<h3>6.1 手工 EVE(不需要 eve-iac)</h3>
<ol>
<li>新建 lab,按 §2 建 6 台 iol + 8 台 vpcs;IOL 的 Ethernet 数量填 1(4 个口)。</li>
<li>按 §3 连 16 条链路:spine 用 Et0/0..0/3 接 4 台 leaf,leaf 用 Et0/0/0/1 上联、Et0/2/Et0/3 接主机。</li>
<li>把附件里 configs/default/n_1.cfg … n_14.cfg 分别粘进对应节点的 Startup Config。</li>
<li>对 6 台 IOL 执行 Wipe,再 Start——顺序不能反(原因见 §8.3)。</li>
<li>启动后按 §7 逐项验收。手工粘贴配置时,务必先 vtp mode transparent,再写 vlan 块。</li>
</ol>
<h3>6.2 IaC 一键复现(eve-iac)</h3>
<p>目录结构与 <code>.eve-iac.yml</code>:</p>
<pre><code class="language-text">vxlan-evpn-xe/
├── .eve-iac.yml
├── topology.yml
└── configs/default/n_1.cfg … n_14.cfg
</code></pre>
<pre><code class="language-yaml">version: 1
topology: topology.yml

eve:
lab: /IaC/vxlan-evpn-xe.unl
</code></pre>
<p><code>topology.yml</code>、<code>.eve-iac.yml</code> 与 14 份配置都在附件包里。MCP 调用顺序:</p>
<pre><code class="language-text">eve_iac_status                     # 确认工程被发现,mode=create
eve_iac_validate                     # 拓扑 + 10 条 BPF 表达式编译
eve_iac_plan                         # 首次应为 create
eve_iac_deploy replace=true          # 建 lab
eve_iac_start                        # 启动全部节点
</code></pre>
<p>两条工具边界:<code>eve_iac_deploy</code> 返回 <code>timeout</code> 多半是假失败,先 <code>inspect refresh=true</code> 看结果再决定是否重试;0.9.1 下改启动配置后 <code>reconcile</code> 只上传不激活,**要生效必须手动 <code>stop → wipe → start</code>**(wipe 需明确授权)。</p>
<h2>7. 验收判据</h2>
<h3>7.1 Underlay</h3>
<pre><code class="language-text">show ip ospf neighbor
</code></pre>
<p>期望每台 leaf 两个 <code>FULL/ -</code>(对端 <code>10.0.1.1</code>、<code>10.0.2.1</code>),spine 侧看到 4 个 <code>FULL</code>。<code>show ip route</code> 里应能看到其他所有设备的 <code>10.255.0.x/32</code> 环回。</p>
<h3>7.2 Overlay 控制面</h3>
<pre><code class="language-text">show bgp l2vpn evpn summary
</code></pre>
<p>期望两台邻居 <code>Established</code>、<code>PfxRcd &gt; 0</code>(实测 24 = 3 台远端 leaf × 每台 8 条;主机上下线时会掉,<strong>不要死记数字</strong>)。</p>
<pre><code class="language-text">show nve vni
show nve peers
</code></pre>
<p>期望 <code>show nve vni</code> 4 个 VNI 全 <code>Up</code>;<code>show nve peers</code> 每个 VNI 都有 3 个远端 VTEP,共 12 个 <code>Up</code>。</p>
<pre><code class="language-text">show l2vpn evpn mac ip
</code></pre>
<p>期望 8 条主机记录:<strong>本地主机</strong> <code>Next Hop</code> 是 <code>Et0/2:10</code> / <code>Et0/3:20</code>(接口:VLAN),<strong>远端主机</strong>是对端 VTEP 的环回(<code>10.255.0.12/13/14</code>)。这 8 条齐全,说明 type-2 路由已经跨 leaf 交换完成。</p>
<h3>7.3 数据面:TTL 是最便宜的判据</h3>
<p>验收全部在 VPCS 上做,不要用 IOL 自己 ping 自己。</p>
<table>
<thead>
<tr>
<th>源</th>
<th>目的</th>
<th>路径</th>
<th>预期</th>
<th>判据</th>
</tr>
</thead>
<tbody>
<tr>
<td>HOST-B1</td>
<td>10.10.30.12(HOST-B3)</td>
<td>同 VLAN 30,LEAF3 → LEAF4</td>
<td>5/5</td>
<td>**<code>ttl=64</code>**:纯二层桥接</td>
</tr>
<tr>
<td>HOST-B1</td>
<td>10.10.40.12(HOST-B4)</td>
<td>跨 VLAN 30 → 40,LEAF3 → LEAF4</td>
<td>5/5</td>
<td>**<code>ttl=63</code>**:恰好一跳</td>
</tr>
<tr>
<td>HOST-B1</td>
<td>10.10.40.11(HOST-B2)</td>
<td>跨 VLAN,同 LEAF3</td>
<td>5/5</td>
<td><code>ttl=63</code></td>
</tr>
<tr>
<td>HOST-B1</td>
<td>10.10.10.11(HOST-A1)</td>
<td>跨 VLAN 30 → 10,LEAF3 → LEAF1</td>
<td>5/5</td>
<td><code>ttl=63</code></td>
</tr>
<tr>
<td>HOST-B3</td>
<td>10.10.30.11(HOST-B1)</td>
<td>同 VLAN 反向</td>
<td>5/5</td>
<td><code>ttl=64</code></td>
</tr>
</tbody>
</table>
<pre><code class="language-text">HOST-B1&gt; ping 10.10.30.12 -c 5
84 bytes from 10.10.30.12 icmp_seq=1 ttl=64 time=1.726 ms
...
HOST-B1&gt; ping 10.10.40.12 -c 5
84 bytes from 10.10.40.12 icmp_seq=1 ttl=63 time=3.566 ms
...
</code></pre>
<blockquote>
<p>同 VLAN 出现 <code>63</code>,说明它被某个 SVI 路由了一次,路径就不对了。TTL 比“ping 通”精确得多。</p>
</blockquote>
<h3>7.4 Traffic filters:该亮什么、该不亮什么</h3>
<p>10 条过滤器(<code>timeout</code> 全部 500 ms):</p>
<table>
<thead>
<tr>
<th>#</th>
<th>标题</th>
<th>表达式</th>
<th>颜色</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>ARP-Request</td>
<td><code>(arp and arp = 1) or (vlan and arp and arp = 1)</code></td>
<td><code>#00e5ff</code></td>
</tr>
<tr>
<td>2</td>
<td>ARP-Reply</td>
<td><code>(arp and arp = 2) or (vlan and arp and arp = 2)</code></td>
<td><code>#76ff03</code></td>
</tr>
<tr>
<td>3</td>
<td>ICMP-Request</td>
<td><code>(icmp == 8) or (vlan and icmp == 8)</code></td>
<td><code>#ff4081</code></td>
</tr>
<tr>
<td>4</td>
<td>ICMP-Reply</td>
<td><code>(icmp == 0) or (vlan and icmp == 0)</code></td>
<td><code>#651fff</code></td>
</tr>
<tr>
<td>5</td>
<td>OSPF-Hello</td>
<td><code>(ip proto 89 and ip = 1) or (vlan and ip proto 89 and ip = 1)</code></td>
<td><code>#ffd600</code></td>
</tr>
<tr>
<td>6</td>
<td>BGP-EVPN</td>
<td><code>(tcp port 179) or (vlan and tcp port 179)</code></td>
<td><code>#ff6d00</code></td>
</tr>
<tr>
<td>7</td>
<td>VXLAN-All</td>
<td><code>(udp port 4789) or (vlan and udp port 4789)</code></td>
<td><code>#00b8d4</code></td>
</tr>
<tr>
<td>8</td>
<td>VXLAN-VNI-10010</td>
<td><code>(udp port 4789 and udp = 0x0027 and udp = 0x1a) or (vlan and udp port 4789 and udp = 0x0027 and udp = 0x1a)</code></td>
<td><code>#c6ff00</code></td>
</tr>
<tr>
<td>9</td>
<td>VXLAN-VNI-10030</td>
<td><code>(udp port 4789 and udp = 0x0027 and udp = 0x2e) or (vlan and udp port 4789 and udp = 0x0027 and udp = 0x2e)</code></td>
<td><code>#ff00e5</code></td>
</tr>
<tr>
<td>10</td>
<td>VXLAN-Inner-ARP</td>
<td><code>(udp port 4789 and udp = 0x0806) or (vlan and udp port 4789 and udp = 0x0806)</code></td>
<td><code>#ffab00</code></td>
</tr>
</tbody>
</table>
<p>在 EVE 的 <strong>Traffic Filters</strong> 面板里,期望看到:</p>
<table>
<thead>
<tr>
<th>观察位置</th>
<th>应亮</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>接入链路(leaf ↔ 主机)</td>
<td><code>ARP-Request/Reply</code>、<code>ICMP-Request/Reply</code></td>
<td>主机帧不打标,VLAN 变体那半段不匹配</td>
</tr>
<tr>
<td>underlay 链路(spine ↔ leaf)</td>
<td><code>OSPF-Hello</code>、<code>BGP-EVPN</code>、<code>VXLAN-All</code></td>
<td>BGP keepalive 间隔长,高亮只闪一下</td>
</tr>
<tr>
<td>同 VLAN ping(B1 → B3)</td>
<td><code>VXLAN-VNI-10030</code>亮,**<code>VXLAN-VNI-10010</code>不亮**</td>
<td>二层流量只在 VLAN 30 的 VNI 里走</td>
</tr>
<tr>
<td>跨 VLAN ping(B1 → A1)</td>
<td><strong><code>VXLAN-VNI-10010</code>亮</strong>,<code>VXLAN-VNI-10030</code>不亮</td>
<td>网关路由后,帧进了目标 VLAN 的 VNI</td>
</tr>
<tr>
<td>任一次首次 ping</td>
<td><code>VXLAN-Inner-ARP</code>亮</td>
<td>ARP 请求被泛洪进 VXLAN</td>
</tr>
<tr>
<td><strong>underlay 链路</strong></td>
<td><strong><code>ICMP-Request/Reply</code>不亮</strong></td>
<td>最漂亮的一条反证:ICMP 已被封进 UDP 4789,外层协议号是 17,<code>icmp[]</code>匹配不到</td>
</tr>
</tbody>
</table>
<blockquote>
<p>命中次数只能在 EVE 面板看,MCP 没有读通道。500 ms 窗口下零星报文可能漏抓,<strong>发 5–10 次 ping 再观察</strong>。</p>
</blockquote>
<p>BPF 写法注意:这些是 <strong>classic libpcap/tcpdump 语法</strong>,不是 Wireshark 显示过滤器;<code>proto</code> 的 size 只能是 1/2/4,所以 VNI 必须拆成 <code>udp</code> + <code>udp</code>(<code>udp</code> 编译不过);<strong>VLAN 变体必须加括号</strong>,<code>and</code>/<code>or</code> 同级左结合,<code>vlan and A or B</code> 只会让 <code>vlan</code> 约束 <code>A</code>;OSPF 类型字节在 <code>ip</code> 而不是 <code>ip</code>。</p>
<h3>7.5 判据的边界</h3>
<ul>
<li>不要只凭 ping 判断成功:show l2vpn evpn mac ip 的 8 条记录和 show nve peers 的 12 个 Up 才是控制面真的工作了的证据。</li>
<li>show ip interface brief 会多出一个 Tunnel0,IP 与 Loopback0 相同并 up/up——这是 XE 为 VXLAN 自动生成的,不是配错。</li>
<li>show interfaces nve1 的计数器恒为 0,隧道 MAC 也不进普通 MAC 表;这是 IOL 的实现限制,不是隧道没通。</li>
</ul>
<h2>8. 踩坑清单(按“会骗到你”的程度排序)</h2>
<h3>8.1 镜像不对:15.2 的 adv 镜像根本没有 VXLAN/EVPN ★最根本</h3>
<p><code>interface nve1</code> 和 <code>l2vpn evpn</code> 两条命令都报 <code>% Invalid input detected at '^' marker</code>。<strong>不是配置写错,是镜像没有这个功能。</strong> 判断方法只有一个:进全局配置敲这两条,都能进才算支持。不要看版本号或文件名猜。</p>
<h3>8.2 L2 VNI 只配 <code>member vni</code> 不出路由 ★</h3>
<p>只在 <code>interface nve1</code> 下写 <code>member vni 10010</code> + <code>ingress-replication</code>,会得到:**BGP 会话 Established,但 <code>show bgp l2vpn evpn</code> 全空、<code>PfxRcd = 0</code>**。必须补 EVI(<code>l2vpn evpn instance</code> + <code>vlan configuration</code> → <code>member evpn-instance</code>)。这是最容易“看起来配了其实没配”的一处:underlay 健康、会话健康,只有 overlay 是空的。</p>
<h3>8.3 <code>vlan.dat</code> 跨 stop/start 保留,会毒化启动解析 ★</h3>
<p>同一份启动配置,在旧 <code>vlan.dat</code> 上 <code>stop → start</code>:<code>vlan</code> 块名字不更新(<code>VLAN0010</code> 而不是 <code>WEB</code>),<code>switchport voice vlan</code> 行直接从 <code>running-config</code> 消失;<strong>wipe 后 start 则 100% 正确</strong>。所以首次导入配置后要 wipe 再 start,改过 VLAN 结构后也要 wipe 再 start。用 stop+start 验证预配配置,只会得到“配置没生效”的假象。</p>
<h3>8.4 必须 <code>vtp mode transparent</code>,否则 VLAN 块被静默吞掉 ★</h3>
<p>IOL 默认 VTP Server 模式,启动配置里的 <code>vlan 10 / name WEB</code> 整块可能被<strong>静默丢弃</strong>:VLAN 不存在,但接口下的 <code>switchport access vlan 10</code> 却留着。症状是 <code>show vlan brief</code> 里没有 VLAN 10、主机完全不通。验证用 <code>show vtp status</code>,应显示 <code>Transparent</code>。</p>
<h3>8.5 <code>no autostate</code> 救不了“开机时没有 up 端口”的 SVI ★</h3>
<p>每台 leaf 只有 4 个 VLAN 里的 2 个有 access 口,另外 2 个的 SVI 在创建瞬间本地没有 active 端口 → 初始 down;<code>no autostate</code> 是运行态属性,<strong>拉不起已经 down 的 SVI</strong>。反过来在启动配置里写 <code>shutdown</code> + <code>no shutdown</code> 想“手动拉一把”,解析时会被合并,也无效。唯一稳妥的解法是 <code>switchport voice vlan &lt;缺失 VLAN&gt;</code>。</p>
<p>于是 <code>show vlan brief</code> 会看到“反直觉”的一幕:LEAF1 的 <code>Et0/2</code> 是 access VLAN 10,却同时关联 VLAN 30。这是故意的,不是配错。</p>
<h3>8.6 IOL 的 trunk 口不接受 VPCS 的 untagged 流量 ★</h3>
<p>主机口配成 <code>switchport mode trunk</code> + native VLAN + <code>portfast trunk</code>:SVI 全 up,但接在该口的 VPCS <strong>完全不通</strong>,接口输入计数为 0。改回 <code>switchport mode access</code> 立刻恢复。VPCS 不打标签,IOL 的 trunk 口也不收 untagged 入向帧——主机口只能 access。</p>
<h3>8.7 anycast 网关三件套缺一不可 ★</h3>
<p>同 IP、同 MAC(<code>0000.5e00.0101</code>)、<code>no ip proxy-arp</code>。少 MAC,主机换 leaf 后 ARP 缓存失效;少 <code>no ip proxy-arp</code>,某台 leaf 可能用自己的 anycast MAC 代替远端主机应答,把“远端主机自己的 ARP 应答”变成“网关代理应答”,破坏 MAC-IP 学习的判据。</p>
<h3>8.8 权限级别:<code>show running-config</code> / <code>ping source</code> 要先 <code>enable</code></h3>
<p><code>show running-config</code> 在 <code>LEAF1&gt;</code>(user exec)下报 <code>Invalid input</code>,不是镜像坏了,只是权限不够;<code>ping</code> 带 <code>source</code> / <code>repeat</code>、<code>clear arp-cache</code> 同样只在特权模式可用。<strong>在 user exec 下测出的“这命令不存在”结论全都不可信。</strong></p>
<h3>8.9 BGP EVPN 的三个必配项</h3>
<p><code>address-family l2vpn evpn</code> + <code>activate</code>(否则不交换 EVPN 路由)、<code>send-community extended</code>(否则扩展团体传不过去)、spine 上的 <code>route-reflector-client</code>(leaf 只与 spine 建邻居,没有 RR 配置 leaf 之间收不到彼此的路由)。另外:<code>l2vpn evpn</code> 下的 <code>router-id</code> 要写<strong>接口名</strong> <code>Loopback0</code> 而不是 IP;<code>nve1</code> 的 <code>source-interface</code> 只接受 Loopback;<code>host-reachability protocol bgp</code> 不能漏。</p>
<h3>8.10 三个容易漏的单行配置</h3>
<table>
<thead>
<tr>
<th>漏了</th>
<th>症状</th>
</tr>
</thead>
<tbody>
<tr>
<td>leaf 上的 <code>ip routing</code></td>
<td>SVI 有地址但不转发,跨 VLAN 完全不通</td>
</tr>
<tr>
<td>uplink 上的 <code>no switchport</code></td>
<td>口还是二层口,IP 配不进去,OSPF 起不来</td>
</tr>
<tr>
<td>uplink 上的 <code>ip ospf network point-to-point</code></td>
<td>OSPF 选 DR/BDR,收敛行为与预期不符</td>
</tr>
</tbody>
</table>
<h3>8.11 VPCS 的语法与控制台有损</h3>
<p><code>set pcname HOST-A1</code> 的 <code>set</code> 不能漏,漏了报 <code>unknown VPCS command</code>,而且会让整批 <code>config_edit</code> 原子失败(同批其他节点配置一起不落盘)。控制台偶尔整条空读、或只把最后一行吞进提示符、或报 <code>Bad command: &quot;pipe2 failed&quot;</code>;对策是<strong>以“读到的内容是否满足预期”作判据</strong>,不满足就退避重读,连续失败对这台 VPCS 做一次 stop → start(不用 wipe)。</p>
<h3>8.12 排障顺序</h3>
<p>从下往上查,不要一上来就怀疑 VXLAN:① 镜像能不能进 <code>nve1</code> / <code>l2vpn evpn</code>(§8.1)→ ② <code>show ip interface brief</code> 的 uplink 和 SVI 是否 up/up → ③ <code>show ip ospf neighbor</code> 是否 FULL → ④ <code>show bgp l2vpn evpn summary</code> 是否 Established、PfxRcd &gt; 0 → ⑤ <code>show nve vni</code> / <code>show nve peers</code> → ⑥ <code>show l2vpn evpn mac ip</code> 是否 8 条 → ⑦ 最后才在 VPCS 上 ping 看 TTL。</p>
<h2>9. 已知限制</h2>
<ul>
<li>没有 L3 VNI / 对称 IRB:刻意。跨子网靠每台 leaf 的 anycast SVI 本地路由 + L2 VNI 转发,不覆盖 VRF-aware EVPN。</li>
<li>没有 EVPN 多归属 / ESI:每台主机只挂一台 leaf,练不了 all-active 和别名 MAC。</li>
<li>没有做故障收敛测试:拓扑有双 uplink 冗余,但没测过挂掉一台 spine 的收敛时间。</li>
<li>没验 VXLAN MTU / 分片:全是小包 ping,撞不到 underlay MTU 边界。</li>
<li>只有 2 个 VNI 配了专用过滤器:10010 / 10030 作代表;10020 / 10040 照抄改 udp 为 0x24 / 0x38 即可。</li>
<li>IOL 的 NVE 计数器不可用:恒为 0,只能用控制面表验证。</li>
<li>版本敏感:实测基于 IOS-XE 17.18.2;其他版本请先确认 interface nve1 与 show l2vpn evpn mac ip 的输出格式。</li>
</ul>
<h2>10. 附录</h2>
<h3>10.1 A. 附件包(完整预配 + IaC)</h3>
<p>完整配置与 IaC 文件打包为 **<code>vxlan-evpn-xe.zip</code>**(约 228 KB)。下载方式(发布时替换):</p>
<blockquote>
<p>???? <code>&lt;TODO:网盘链接 / 公众号自动回复关键字 / 阅读原文&gt;</code></p>
</blockquote>
<p>包内结构:</p>
<pre><code class="language-text">vxlan-evpn-xe/
├── README.md               # 文件清单、双路径复现、校验方法
├── .eve-iac.yml            # 工程描述符(eve.lab 需改成你的路径)
├── topology.yml            # 14 节点 / 16 链路 / 10 条 traffic_filters
├── topology.png            # 拓扑图(2560×1440)
└── configs/default/
    ├── n_1.cfg … n_6.cfg   # SPINE1/2、LEAF1..4
    └── n_7.cfg … n_14.cfg    # HOST-A1..A4、HOST-B1..B4
</code></pre>
<p>配置文件 SHA-256(按原始字节计算,无结尾换行,与 <code>eve_iac_config index</code> 一致):</p>
<table>
<thead>
<tr>
<th>文件</th>
<th>字节</th>
<th>SHA-256</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>n_1.cfg</code></td>
<td>1915</td>
<td><code>d16b1db7e41b6530a6774112c2334857f61717ece019d3de4f649d296f30f100</code></td>
</tr>
<tr>
<td><code>n_2.cfg</code></td>
<td>1915</td>
<td><code>95365555a3f1524871156675f091882058351358ef2813817c29d0001753757e</code></td>
</tr>
<tr>
<td><code>n_3.cfg</code></td>
<td>2914</td>
<td><code>493b41e3533f8105002f111e9ee57f5b89ab8ddd4b9b26e2369c64371c3f28ee</code></td>
</tr>
<tr>
<td><code>n_4.cfg</code></td>
<td>2914</td>
<td><code>d8bc3d3abc31e017ad19082b7e71e4ba2b7c85cbb78b6d04b7a4e267d81ed8fb</code></td>
</tr>
<tr>
<td><code>n_5.cfg</code></td>
<td>2916</td>
<td><code>12b1553e55a1429a787fd5c71858e0f7b12df117b933ff6dbabdd30633e1ba1c</code></td>
</tr>
<tr>
<td><code>n_6.cfg</code></td>
<td>2916</td>
<td><code>f9dad2c1c78a06cb8465b5be6414f9147115897ec39b8378ed0ad473fcfee165</code></td>
</tr>
<tr>
<td><code>n_7.cfg</code></td>
<td>47</td>
<td><code>3f1b83dcdcc6a3206d35a9cfc037022ec2da94ffbea4ed48ca7b656ead203f64</code></td>
</tr>
<tr>
<td><code>n_8.cfg</code></td>
<td>47</td>
<td><code>a7083c29d157c5519cc41e9f7125409a1b602c8333e22ecf0e77c633b493b9a8</code></td>
</tr>
<tr>
<td><code>n_9.cfg</code></td>
<td>47</td>
<td><code>8f12c31fb669170472f7d2b9594bcab0d07daca679b6f7b3a14978b342e265f6</code></td>
</tr>
<tr>
<td><code>n_10.cfg</code></td>
<td>47</td>
<td><code>293ba9b28d61c4991b9dc3a5b882759edcc9e8d97815fdc229749e66f3c8878f</code></td>
</tr>
<tr>
<td><code>n_11.cfg</code></td>
<td>47</td>
<td><code>2dc96240376b3b8082f62c5a8b653acb88305728a9bd63879666a8b635e0f94a</code></td>
</tr>
<tr>
<td><code>n_12.cfg</code></td>
<td>47</td>
<td><code>59ab615593c81e5ee162851e5e10f420c819e6207fc8f40f8fc4b013fe6aa778</code></td>
</tr>
<tr>
<td><code>n_13.cfg</code></td>
<td>47</td>
<td><code>2b71aa599606c5f865b75655120713643093240539316aaa1f16f7fb60153980</code></td>
</tr>
<tr>
<td><code>n_14.cfg</code></td>
<td>47</td>
<td><code>14aee65642123725a74110df7b1bc2fc516879851f425b03b94a132e872ea19e</code></td>
</tr>
</tbody>
</table>
<p>下载后核对(PowerShell):<code>Get-FileHash .\configs\default\n_1.cfg -Algorithm SHA256</code>。</p>
<h3>10.2 B. topology.yml 结构</h3>
<p>完整 <code>topology.yml</code> 在附件包里,核心结构如下(省略部分节点、链路与 filter):</p>
<pre><code class="language-yaml">version: eve-iac/v1
name: vxlan-evpn-xe

configsets:
default:
    n_1: configs/default/n_1.cfg
    # n_2 … n_14 同理

nodes:
n_1:
    name: SPINE1
    template: iol
    image: l2-iol-xe-17-18-02.bin
    configset: default
    icon: Router-2D-Cat-Blue-S.svg
    position: {x: 450, y: 80}
    attributes: {delay: 0, disable_offload: false, ethernet: 1, keepalive: false,
               nvram: 1024, ram: 1024, serial: 0}
# n_2 … n_14 同理

links:
- endpoints: - {node: n_1, interface: e0/0}
      - {node: n_3, interface: e0/0}
# 其余 15 条链路同理

traffic_filters:
filter_1:
    title: ARP-Request
    expr: &quot;(arp and arp = 1) or (vlan and arp and arp = 1)&quot;
    color: &quot;#00e5ff&quot;
    timeout: 500
    enabled: 1
# filter_2 … filter_10 见 §7.4
</code></pre>
<h3>10.3 C. MCP 调用序列(对照用)</h3>
<pre><code class="language-text">eve_iac_status
eve_iac_validate
eve_iac_plan
eve_iac_deploy replace=true
eve_iac_start
eve_iac_console_exec{node: &quot;n_3&quot;, command: &quot;show bgp l2vpn evpn summary&quot;}
eve_iac_console_exec{node: &quot;n_3&quot;, command: &quot;show nve peers&quot;}
eve_iac_console_exec{node: &quot;n_3&quot;, command: &quot;show l2vpn evpn mac ip&quot;}
eve_iac_console_exec{node: &quot;n_11&quot;, command: &quot;ping 10.10.30.12 -c 5&quot;}
</code></pre>
<h3>10.4 D. 版本与验证记录</h3>
<ul>
<li>2026-10-18:首次搭建并实测。IOS-XE 17.18.2(IOL XE)、VPCS 1.3、eve-iac agent 0.9.1。</li>
<li>2026-11-01:按《实验案例发布工作流》重排为发布版;正文只保留核心配置,完整预配、topology.yml、.eve-iac.yml、拓扑图打包进 vxlan-evpn-xe.zip。</li>
<li>验证:eve_iac_plan 为 no changes;10 条 filter 全部编译通过;14 份配置的字节数与 SHA-256 与 eve_iac_config index 逐一核对一致。</li>
<li>实测通过:OSPF FULL、EVPN Established、nve peers 12 个 Up、MAC-IP 8 条、5 组 ping 5/5(ttl=64 / ttl=63)。</li>
</ul>
页: [1]
查看完整版本: 实验案例:Cisco IOL XE 跑通 VXLAN EVPN