三段式VXLAN实现三层互通
1 组网需求
数据中心A和数据中心B规划在不同的BGP AS域,在数据中心内部配置BGP EVPN协议创建分布式网关VXLAN隧道,实现同一数据中心Server1和Server2之间的互通、Server3和Server4之间的互相通信,通过在Leaf2和Leaf3之间配置BGP EVPN协议创建VXLAN隧道,实现数据中心A和数据中心B之间的互相通信(例如Server1和Server3、4之间互相通信)。
2 配置思路
采用如下的思路配置跨AS的三段式VXLAN:
- 配置各节点IP地址。
- 配置IGP实现各节点之间的互通。
- 配置静态路由实现数据中心之间的互通。
- 在数据中心A和数据中心B内配置BGP EVPN协议创建分布式网关VXLAN隧道。
- 在Leaf2和Leaf3上配置BGP EVPN协议创建VXLAN隧道。
3 配置过程
3.1 配置各节点IP地址(略)
3.2 配置IGP实现各节点之间的互通
3.2.1 Spine1
#
ospf 1
opaque-capability enable
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 192.168.10.0 0.0.0.255
network 192.168.20.0 0.0.0.255
#
3.2.2 Spine2
#
ospf 1
opaque-capability enable
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 192.168.30.0 0.0.0.255
network 192.168.40.0 0.0.0.255
#
3.2.3 Leaf1
#
ospf 1
opaque-capability enable
area 0.0.0.0
network 5.5.5.5 0.0.0.0
network 192.168.10.0 0.0.0.255
#
3.2.4 Leaf2
#
ospf 1
opaque-capability enable
area 0.0.0.0
network 6.6.6.6 0.0.0.0
network 192.168.20.0 0.0.0.255
#
ip route-static 7.7.7.7 255.255.255.255 192.168.50.1
ip route-static 192.168.1.0 255.255.255.0 192.168.50.1
ip route-static 192.168.60.0 255.255.255.0 192.168.50.1
#
3.2.5 NE-1
#
ip route-static 6.6.6.6 255.255.255.255 192.168.50.2
ip route-static 7.7.7.7 255.255.255.255 192.168.1.2
ip route-static 192.168.60.0 255.255.255.0 192.168.1.2
#
3.2.6 NE-2
#
ip route-static 6.6.6.6 255.255.255.255 192.168.1.1
ip route-static 7.7.7.7 255.255.255.255 192.168.60.2
ip route-static 192.168.50.0 255.255.255.0 192.168.1.1
#
3.2.7 Leaf3
#
ospf 1
area 0.0.0.0
network 7.7.7.7 0.0.0.0
network 192.168.30.0 0.0.0.255
#
ip route-static 6.6.6.6 255.255.255.255 192.168.60.1
ip route-static 192.168.1.0 255.255.255.0 192.168.60.1
ip route-static 192.168.50.0 255.255.255.0 192.168.60.1
#
3.2.8 Leaf4
#
ospf 1
area 0.0.0.0
network 8.8.8.8 0.0.0.0
network 192.168.40.0 0.0.0.255
#
3.3 创建分布式网关VXLAN隧道
3.3.1 Leaf1
#
evpn vpn-instance evrf1 bd-mode # 创建evpn实例
route-distinguisher 10:1
vpn-target 11:1 both
#
ip vpn-instance vpn1 # 创建ipv4 vpn实例
ipv4-family
route-distinguisher 11:11
apply-label per-instance # 使能每实例每标签的标签分配方式
vpn-target 1:1 both
vpn-target 11:1 both evpn # 对应evpn实例中的RT
vxlan vni 5010
#
bridge-domain 10
vxlan vni 10 split-horizon-mode # 指定按照水平分割方式进行转发
evpn binding vpn-instance evrf1 # 绑定evpn实例
#
interface Vbdif10 # 进入三层网关接口
ip binding vpn-instance vpn1 # 绑定ipv4 vpn实例
ip address 10.10.1.1 255.255.255.0
vxlan anycast-gateway enable # 使能分布式网关功能
arp collect host enable # 基于VBDIF接口粒度进行主机信息搜集的功能
#
interface GigabitEthernet3/0/8.1 mode l2 # 进入二层子接口视图
encapsulation dot1q vid 10 # 指定二层子接口接收带指定802.1Q Tag封装的报文
rewrite pop single # 指定EVC二层子接口对接收的报文进行剥除一层VLAN Tag操作
bridge-domain 10 # 将子接口加入BD
#
bgp 100
private-4-byte-as enable
peer 6.6.6.6 as-number 100
peer 6.6.6.6 connect-interface LoopBack0
#
ipv4-family vpn-instance vpn1
import-route direct # 在bgp的vpn实例中引入静态路由
advertise l2vpn evpn # 使能VPN实例发布EVPN的IP前缀路由功能,即Type-5 Prefix-route
#
l2vpn-family evpn # 使能并进入BGP-EVPN地址族视图
undo policy vpn-target # 取消对VPN路由的VPN Target过滤,接收所有VPN路由
peer 6.6.6.6 enable
peer 6.6.6.6 advertise irb # 配置发布IRB类型的路由
peer 6.6.6.6 advertise encap-type vxlan # 向邻居发布的EVPN路由所携带的封装属性为vxlan
#
interface Nve1
source 5.5.5.5
vni 10 head-end peer-list protocol bgp # 用BGP协议动态建立VNI的头端复制列表
#
Leaf2、3、4的配置类似,这里不在赘述。
需要注意的是,Leaf2、3、4的vbdif接口地址分别如下:
# Leaf2
interface Vbdif20
ip binding vpn-instance vpn1
ip address 10.20.1.1 255.255.255.0
# Leaf3
interface Vbdif10
ip binding vpn-instance vpn1
ip address 10.30.1.1 255.255.255.0
# Leaf4
interface Vbdif20
ip binding vpn-instance vpn1
ip address 10.40.1.1 255.255.255.0
该步骤结束后数据中心A、B内部的VxLAN隧道就简历成功了:
Leaf1 & Leaf2
Leaf3 & Leaf4
3.4 在Leaf2和Leaf3上配置BGP EVPN协议创建VXLAN隧道
由于Leaf2和Leaf3上存在VPN实例和EVPN实例,因此在Leaf2和Leaf3上配置仅需要配置EBGP EVPN对等体,保证IP路由可达即可。
3.4.1 Leaf2
#
bgp 100
peer 7.7.7.7 as-number 200
peer 7.7.7.7 ebgp-max-hop # 允许BGP同非直连网络上的对等体建立EBGP连接,如果配置peer ebgp-max-hop命令时不指定hop-count参数,则缺省跳数为255
peer 7.7.7.7 connect-interface LoopBack0 # 使用非直连接口进行EBGP建立,前提是有路由可达
#
ipv4-family vpn-instance vpn1
import-route direct
advertise l2vpn evpn
#
l2vpn-family evpn
undo policy vpn-target
peer 7.7.7.7 enable
peer 7.7.7.7 advertise irb # 配置发布IRB类型的路由
peer 7.7.7.7 advertise encap-type vxlan # 向邻居发布的EVPN路由所携带的封装属性为vxlan
peer 7.7.7.7 import reoriginate # 使能从对等体收到的路由打上重生路由标记功能
# 缺省情况下,重生标记路由功能是去使能的,即设备收到从对等体发送的路由,不会再对这些路由重新封装
# 因此,设备对VPNv4路由重新封装之前,必须配置peer import reoriginate命令使能重生标记路由功能。
peer 7.7.7.7 advertise route-reoriginated evpn ip # 向对等体发布EVPN地址族重新生成后的路由
#
3.4.2 Leaf3
bgp 200
peer 6.6.6.6 as-number 100
peer 6.6.6.6 ebgp-max-hop 255
peer 6.6.6.6 connect-interface LoopBack0
#
ipv4-family vpn-instance vpn1
import-route direct
advertise l2vpn evpn
#
l2vpn-family evpn
undo policy vpn-target
peer 6.6.6.6 enable
peer 6.6.6.6 advertise irb
peer 6.6.6.6 advertise encap-type vxlan
peer 6.6.6.6 import reoriginate
peer 6.6.6.6 advertise route-reoriginated evpn ip
4 配置验证
4.1 VXLAN 隧道建立
Leaf2 & Leaf3
4.2 ipv4 vpn-instance路由
4.3 BGP EVPN 路由
以Leaf1为例进行查看:
4.4 访问测试
以Server1为例进行访问测试:
至此,本案例配置结束。