本文将基于 Juniper vQFX 与 vMX 平台,完整演示如何部署由 BGP-EVPN 作为控制平面的跨数据中心 VXLAN 互联网络。
实验拓扑与跨数据中心二层互联需求
数据中心互联核心需求:
- DC-A 与 DC-B 通过点对点本地环路(Local-Loop)互联为统一的骨干传输域;
- 两地交换机下挂的客户二层域(
cust/cust2)需要跨越三层核心合并为逻辑上的同一二层广播域,并具备跨网段 Anycast 三层网关能力。
为什么数据中心互联优先选择 EVPN + VXLAN?
在实现跨数据中心二层延伸时,常见技术路线主要有三类:
- VPLS:功能成熟,但全互联信令与水平分割对拓扑限制较大,且并非所有三层交换机都原生支持;
- MPLS L2Circuit(Pseudowire):更适用于点到点专线透明传输(可参考后续教程《Juniper MPLS L2Circuit(Ethernet-CCC)虚拟网线实战》),多业务 VLAN 扩展较繁琐;
- BGP-EVPN + VXLAN:将控制面(MP-BGP EVPN)与数据面(VXLAN UDP 封装)解耦,能像传统 VLAN 一样灵活隔离租户流量并天然支持 Anycast IRB 网关,现代数据中心交换机普遍原生支持。
一、配置 Underlay 网络(OSPF + MPLS/LDP)
首先搭建 Underlay 底层传输网络:采用 OSPF Area 0 与 LDP 确保 VTEP 环回口(10.0.0.1 与 10.0.0.4)互通。提示:单纯承载 VXLAN 数据面仅需 IGP 路由可达即可,但为了方便后续扩展 MPLS L2Circuit 实验,本篇同时开启了 family mpls 与 LDP。部署前请务必将物理接口 MTU 调大至 9000(或至少大于 1550 字节以容纳 VXLAN 外层开销)。
root> show system rollback compare 4 0
[edit]
+ interfaces {
+ ge-0/0/0 {
+ unit 0 {
+ family inet {
+ address 192.0.2.1/24;
+ }
+ family mpls;
+ }
+ }
+ ge-0/0/1 {
+ unit 0 {
+ family inet {
+ address 192.0.1.2/24;
+ }
+ family mpls;
+ }
+ }
+ lo0 {
+ unit 0 {
+ family inet {
+ address 10.0.0.2/32;
+ }
+ }
+ }
+ }
+ protocols {
+ mpls {
+ interface ge-0/0/0.0;
+ interface ge-0/0/1.0;
+ }
+ ospf {
+ area 0.0.0.0 {
+ interface ge-0/0/0.0;
+ interface ge-0/0/1.0;
+ interface lo0.0;
+ }
+ }
+ ldp {
+ transport-address 10.0.0.2;
+ interface ge-0/0/0.0;
+ interface ge-0/0/1.0;
+ }
+ }
root> show system rollback compare 3 0
[edit]
+ interfaces {
+ ge-0/0/0 {
+ unit 0 {
+ family inet {
+ address 192.0.2.2/24;
+ }
+ family mpls;
+ }
+ }
+ ge-0/0/1 {
+ unit 0 {
+ family inet {
+ address 192.0.3.1/24;
+ }
+ family mpls;
+ }
+ }
+ lo0 {
+ unit 0 {
+ family inet {
+ address 10.0.0.3/32;
+ }
+ }
+ }
+ }
+ protocols {
+ mpls {
+ interface ge-0/0/0.0;
+ interface ge-0/0/1.0;
+ }
+ ospf {
+ area 0.0.0.0 {
+ interface lo0.0;
+ interface ge-0/0/0.0;
+ interface ge-0/0/1.0;
+ }
+ }
+ ldp {
+ transport-address 10.0.0.3;
+ interface ge-0/0/0.0;
+ interface ge-0/0/1.0;
+ }
+ }
root@vqfx-re> show configuration interfaces xe-0/0/0
unit 0 {
family ethernet-switching {
interface-mode access;
vlan {
members cust;
}
}
}
{master:0}
root@vqfx-re> show configuration interfaces xe-0/0/2
unit 0 {
family ethernet-switching {
interface-mode access;
vlan {
members cust2;
}
}
}
{master:0}
root@vqfx-re> show configuration interfaces lo0
unit 0 {
family inet {
address 10.0.0.1/32;
}
}
{master:0}
root@vqfx-re> show configuration interfaces irb
unit 100 {
family inet {
address 10.10.10.253/24 {
virtual-gateway-address 10.10.10.1;
}
}
}
unit 200 {
family inet {
address 10.10.20.253/24 {
virtual-gateway-address 10.10.20.1;
}
}
}
{master:0}
root@vqfx-re> show configuration vlans
cust {
vlan-id 100;
l3-interface irb.100;
}
cust2 {
vlan-id 200;
l3-interface irb.200;
}
{master:0}
root@vqfx-re> show configuration protocols ospf
area 0.0.0.0 {
interface xe-0/0/1.0;
interface lo0.0;
}
{master:0}
root@vqfx-re> show configuration protocols ldp
transport-address 10.0.0.1;
interface xe-0/0/1.0;
{master:0}
root@vqfx-re> show configuration protocols mpls
interface xe-0/0/1.0;
root@vqfx-re> show configuration interfaces xe-0/0/0
unit 0 {
family ethernet-switching {
interface-mode access;
vlan {
members cust2;
}
}
}
{master:0}
root@vqfx-re> show configuration interfaces xe-0/0/2
unit 0 {
family ethernet-switching {
interface-mode access;
vlan {
members cust;
}
}
}
{master:0}
root@vqfx-re> show configuration interfaces lo0
unit 0 {
family inet {
address 10.0.0.4/32;
}
}
{master:0}
root@vqfx-re> show configuration interfaces irb
unit 100 {
family inet {
address 10.10.10.254/24 {
virtual-gateway-address 10.10.10.1;
}
}
}
unit 200 {
family inet {
address 10.10.20.254/24 {
virtual-gateway-address 10.10.20.1;
}
}
}
{master:0}
root@vqfx-re> show configuration vlans
cust {
vlan-id 100;
l3-interface irb.100;
vxlan {
vni 100;
ingress-node-replication;
}
}
cust2 {
vlan-id 200;
l3-interface irb.200;
vxlan {
vni 200;
ingress-node-replication;
}
}
{master:0}
root@vqfx-re> show configuration protocols ospf
area 0.0.0.0 {
interface lo0.0;
interface xe-0/0/1.0;
}
{master:0}
root@vqfx-re> show configuration protocols ldp
transport-address 10.0.0.4;
interface xe-0/0/1.0;
{master:0}
root@vqfx-re> show configuration protocols mpls
interface xe-0/0/1.0;
配置完成后检查 vMX 的 LDP 邻居,并从 DC-A QFX 的 10.0.0.1 ping 对端 DC-B QFX 的 10.0.0.4,确认 Underlay 连通无误:
# DC-A vMX root> show ldp neighbor Address Interface Label space ID Hold time 192.0.2.2 ge-0/0/0.0 10.0.0.3:0 10 192.0.1.1 ge-0/0/1.0 10.0.0.1:0 14 # DC-B vMX root> show ldp neighbor Address Interface Label space ID Hold time 192.0.2.1 ge-0/0/0.0 10.0.0.2:0 11 192.0.3.2 ge-0/0/1.0 10.0.0.4:0 13 # DC-A QFX root@vqfx-re> ping 10.0.0.4 source 10.0.0.1 PING 10.0.0.4 (10.0.0.4): 56 data bytes 64 bytes from 10.0.0.4: icmp_seq=0 ttl=62 time=133.250 ms 64 bytes from 10.0.0.4: icmp_seq=1 ttl=62 time=147.078 ms 64 bytes from 10.0.0.4: icmp_seq=2 ttl=62 time=100.059 ms ^C --- 10.0.0.4 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max/stddev = 100.059/126.796/147.078/19.731 ms
二、配置 Overlay 网络(BGP-EVPN Signaling + VXLAN)
Underlay 就绪后,在两台 QFX 上配置 AS 65000 内部 iBGP EVPN 邻居、EVPN VXLAN 封装(encapsulation vxlan)、各 VNI 对应的 Export Target,以及基于 policy-statement evpn-import 的 switch-options:
root@vqfx-re> show system rollback compare 2 0
[edit]
+ routing-options {
+ router-id 10.0.0.1;
+ autonomous-system 65000;
+ } // 预配置 BGP Router-id 与 本地 ASN
[edit protocols]
+ bgp {
+ group evpn {
+ type internal;
+ local-address 10.0.0.1;
+ family evpn {
+ signaling;
+ }
+ neighbor 10.0.0.4;
+ }
+ } // 激活 EVPN Signaling,使其能够与邻居交换 MAC/IP 数据并建立 VTEP 之间的连接
+ evpn {
+ encapsulation vxlan; // 配置 EVPN 协议封装模式为 VXLAN
+ extended-vni-list all; // 发送所有 VNI 信息,也可设置为只发送特定 VNI info
+ multicast-mode ingress-replication;
+ vni-options {
+ vni 100 {
+ vrf-target export target:65000:100; // 发送该 VNI 时携带 target:65000:100 扩展团体
+ }
+ vni 200 {
+ vrf-target export target:65000:200; // 同上
+ }
+ }
+ }
[edit]
+ policy-options {
+ policy-statement evpn-import {
+ term 100 {
+ from community v100;
+ then accept;
+ } // 接收 VNI 100 的信息
+ term 200 {
+ from community v200;
+ then accept;
+ } // 接收 VNI 200 的信息
+ term 999 {
+ then reject;
+ }
+ }
+ community v100 members target:65000:100;
+ community v200 members target:65000:200;
+ } // 定义 VXLAN Target community
+ switch-options {
+ service-id 1;
+ vtep-source-interface lo0.0; // 定义 VXLAN VTEP 源接口使用 Loopback
+ route-distinguisher 10.0.0.1:1;
+ vrf-import evpn-import; // 使用上述 Target 策略导入 EVPN-VXLAN 路由
+ vrf-target {
+ target:65000:1;
+ auto;
+ }
+ }
[edit vlans cust]
+ vxlan {
+ vni 100;
+ ingress-node-replication;
+ } // 在 VLAN 上激活 VXLAN VNI
[edit vlans cust2]
+ vxlan {
+ vni 200;
+ ingress-node-replication;
+ }
root@vqfx-re> show system rollback compare 2 0
[edit]
+ routing-options {
+ router-id 10.0.0.4;
+ autonomous-system 65000;
+ }
[edit protocols]
+ bgp {
+ group evpn {
+ type internal;
+ local-address 10.0.0.4;
+ family evpn {
+ signaling;
+ }
+ neighbor 10.0.0.1;
+ }
+ }
+ evpn {
+ encapsulation vxlan;
+ extended-vni-list all;
+ multicast-mode ingress-replication;
+ vni-options {
+ vni 100 {
+ vrf-target export target:65000:100;
+ }
+ vni 200 {
+ vrf-target export target:65000:200;
+ }
+ }
+ }
[edit]
+ policy-options {
+ policy-statement evpn-import {
+ term 100 {
+ from community v100;
+ then accept;
+ }
+ term 200 {
+ from community v200;
+ then accept;
+ }
+ term 999 {
+ then reject;
+ }
+ }
+ community v100 members target:65000:100;
+ community v200 members target:65000:200;
+ }
+ switch-options {
+ service-id 1;
+ vtep-source-interface lo0.0;
+ route-distinguisher 10.0.0.4:1;
+ vrf-import evpn-import;
+ vrf-target {
+ target:65000:1;
+ auto;
+ }
+ }
[edit vlans cust]
+ vxlan {
+ vni 100;
+ ingress-node-replication;
+ }
[edit vlans cust2]
+ vxlan {
+ vni 200;
+ ingress-node-replication;
+ }
三、验证 MAC 转发表、EVPN 路由与跨数据中心二/三层互通
Overlay 配置完成后,首先检查两台 QFX 的以太网交换表(show ethernet-switching table),可以看到对端主机的 MAC 地址均已通过 vtep.32769 动态学习完成:
root@vqfx-DC-A> show ethernet-switching table
MAC flags (S - static MAC, D - dynamic MAC, L - locally learned, P - Persistent static
SE - statistics enabled, NM - non configured MAC, R - remote PE MAC, O - ovsdb MAC)
Ethernet switching table : 6 entries, 6 learned
Routing instance : default-switch
Vlan MAC MAC Logical Active
name address flags interface source
cust 00:50:00:00:09:00 D xe-0/0/0.0
cust 00:50:00:00:0c:00 D vtep.32769 10.0.0.4
cust 02:05:86:71:8b:00 D vtep.32769 10.0.0.4
cust2 00:50:00:00:0a:00 D vtep.32769 10.0.0.4
cust2 00:50:00:00:0b:00 D xe-0/0/2.0
cust2 02:05:86:71:8b:00 D vtep.32769 10.0.0.4
{master:0}
root@vqfx-DC-B> show ethernet-switching table
MAC flags (S - static MAC, D - dynamic MAC, L - locally learned, P - Persistent static
SE - statistics enabled, NM - non configured MAC, R - remote PE MAC, O - ovsdb MAC)
Ethernet switching table : 6 entries, 6 learned
Routing instance : default-switch
Vlan MAC MAC Logical Active
name address flags interface source
cust 00:50:00:00:09:00 D vtep.32769 10.0.0.1
cust 00:50:00:00:0c:00 D xe-0/0/2.0
cust 02:05:86:71:ce:00 D vtep.32769 10.0.0.1
cust2 00:50:00:00:0a:00 D xe-0/0/0.0
cust2 00:50:00:00:0b:00 D vtep.32769 10.0.0.1
cust2 02:05:86:71:ce:00 D vtep.32769 10.0.0.1
{master:0}
继续查看 bgp.evpn.0 路由表,可以看到包含纯 MAC 以及同时携带 MAC + 主机 IP(MAC::IP)的 EVPN Type-2 路由条目已通过 BGP EVPN 信令精准同步:
root@vqfx-DC-A> show route evpn-mac-address 00:50:00:00:0a:00 table bgp.evpn.0
bgp.evpn.0: 14 destinations, 14 routes (14 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
2:10.0.0.4:1::200::00:50:00:00:0a:00/304
*[BGP/170] 02:46:16, localpref 100, from 10.0.0.4
AS path: I, validation-state: unverified
> to 192.0.1.2 via xe-0/0/1.0, Push 299808
2:10.0.0.4:1::200::00:50:00:00:0a:00::10.10.20.100/304
*[BGP/170] 02:46:16, localpref 100, from 10.0.0.4
AS path: I, validation-state: unverified
> to 192.0.1.2 via xe-0/0/1.0, Push 299808
root@vqfx-DC-B> show route evpn-mac-address 00:50:00:00:09:00 table bgp.evpn.0
bgp.evpn.0: 14 destinations, 14 routes (14 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
2:10.0.0.1:1::100::00:50:00:00:09:00/304
*[BGP/170] 02:49:18, localpref 100, from 10.0.0.1
AS path: I, validation-state: unverified
> to 192.0.3.1 via xe-0/0/1.0, Push 299808
2:10.0.0.1:1::100::00:50:00:00:09:00::10.10.10.100/304
*[BGP/170] 02:49:18, localpref 100, from 10.0.0.1
AS path: I, validation-state: unverified
> to 192.0.3.1 via xe-0/0/1.0, Push 299808
最后在 DC-A-Linux9 上检查 ARP 邻居表并实测同 VNI 二层通信(10.10.10.101)与跨 VNI 三层 IRB 网关通信(10.10.20.100):
root@DC-A-Linux9:~# ip nei 10.10.10.101 dev ens3 lladdr 00:50:00:00:0c:00 STALE 10.10.10.1 dev ens3 lladdr 00:00:5e:00:01:01 REACHABLE 10.10.10.253 dev ens3 lladdr 02:05:86:71:ce:00 STALE // 检查 ARP 表,没有问题,已经学习到对端 ARP root@DC-A-Linux9:~# ping 10.10.10.101 PING 10.10.10.101 (10.10.10.101) 56(84) bytes of data. 64 bytes from 10.10.10.101: icmp_seq=1 ttl=64 time=69.3 ms 64 bytes from 10.10.10.101: icmp_seq=2 ttl=64 time=57.10 ms 64 bytes from 10.10.10.101: icmp_seq=3 ttl=64 time=72.9 ms --- 10.10.10.101 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 4ms rtt min/avg/max/mdev = 57.959/66.717/72.871/6.360 ms root@DC-A-Linux9:~# ping 10.10.20.100 PING 10.10.20.100 (10.10.20.100) 56(84) bytes of data. 64 bytes from 10.10.20.100: icmp_seq=1 ttl=63 time=71.1 ms 64 bytes from 10.10.20.100: icmp_seq=2 ttl=63 time=52.3 ms 64 bytes from 10.10.20.100: icmp_seq=3 ttl=63 time=46.3 ms --- 10.10.20.100 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 5ms rtt min/avg/max/mdev = 46.340/56.552/71.054/10.538 ms // 检查数据连通性,经测试,经过 VXLAN L2 / VXLAN L3 的数据包均通信正常。 root@DC-A-Linux9:~# mtr --report 10.10.20.100 Start: 2019-02-18T12:13:49+0000 HOST: DC-A-Linux9 Loss% Snt Last Avg Best Wrst StDev 1.|-- 10.10.10.253 0.0% 10 21.8 27.8 21.8 36.3 5.1 2.|-- 10.10.20.100 0.0% 10 82.0 71.0 47.3 108.7 22.1 // 经过 VXLAN L3 网关通信 root@DC-A-Linux9:~# mtr --report 10.10.10.101 Start: 2019-02-18T12:14:34+0000 HOST: DC-A-Linux9 Loss% Snt Last Avg Best Wrst StDev 1.|-- 10.10.10.101 0.0% 10 66.0 67.3 44.8 111.9 18.2 // 经过 VXLAN L2 通信
实测经 VXLAN 二层桥接与三层 Anycast IRB 网关的转发均零丢包正常,可直接用于生产级跨数据中心互联部署。
总结:Route Target 对 VNI 接入的精细控制
一切 Overlay 网络通信都建立在稳定的 Underlay 之上。而在 BGP-EVPN 控制面中,VPN Target(Route Target)分为两类:
- Export Target:本端在发送 EVPN 路由时,在扩展团体属性中附带的导出标签(本例分别在
vni-options中为 VNI 100/200 打上target:65000:100与target:65000:200); - Import Target:本端接收对端 EVPN 路由时,将其携带的 Export Target 与本地
evpn-import策略匹配,匹配则接收、否则丢弃。
因此,在多租户场景下只需灵活修改 evpn-import 策略,即可精确控制各台叶子交换机需要引入或过滤哪些 VNI(VLAN)。