vxlan 动态三层通信_方式2_通过 BGP EVPN Type 2 MAC Route(IRB路由)

一、拓扑:

二、配置思路:

1、配置 ISP 公网底层互通

2、PE 之间建立 BGP EVPN 关系,做为控制平面

复制代码
l2vpn-family evpn
  peer x.x.x.x enable
  peer x.x.x.x advertise encap-type vxlan	#通告时,要支持 vxlan 类型的路由:Type 2、3、5
  peer x.x.x.x advertise irb	#开启发送irb路由功能,默认不发

3、PE 创建 EVI,使用 BD-Mode

复制代码
evpn vpn-instance 1 bd-mode	#由于 vxlan 不是用 esi 来区分用户,而是用 BD 来区分用户,所以用 BD模式
  route-distinguisher 1:1
  vpn-target 1:1

4、PE 创建 BD,并绑定 EVI(3、4 配置二层实例)

复制代码
bridge-domain 100
  vxlan vni 5000 split-horizon-mode	#创建 VNI 并关联 BD,然后按照水平分割方式进行转发,因为没有 ESI 号,这里用 vni 进行防环
 evpn binding vpn-instance 1

5、PE 上创建三层 IP实例,vpn-target 使用 evpn 模式,配置三层 vni(IRB路由需要用):

复制代码
ip vpn-instance 1
 ipv4-family
  route-distinguisher 11:11
  vpn-target 11:11 export-extcommunity evpn
  vpn-target 22:22 import-extcommunity evpn
  vpn-target 2:2 import-extcommunity evpn		#这里要把 evpn 实例2 的 vpn-target 配到 三层实例中,因为 evpn 路由只在二层运行
 vxlan vni 1000

6、PE 上创建 vbdif,绑定三层实例(5、6 配置三层实例)

复制代码
int vbdif 10
  ip binding vpn-instance 1
  ip addr 10.1.1.254 24
 arp collect host enable	#为防止广播流量泛洪,开启这个收集主机路由后,本地会产生一个Type 2 mac-route,带有mac和ip地址的,发给对方。

7、PE 配置 NVE,开启 vxlan 隧道

复制代码
interface nve 1
  source 1.1.1.1
  vni 100 head-end peer-list protocol bgp
  vni 200 head-end peer-list protocol bgp
dis vxlan tunnel

8、PE 配置 VAP

复制代码
interface ethernet 1/0/1.10 mode l2
   encapsulation dot1q vid 10
   rewrite pop single	#NE5000接入二层接口后,不会像CE12800一样自动弹出 vlan 标签,需要手动弹出一下vtag
   bridge-domain 100

三、验证:

1、从 PC1 到 PC4 跟踪一下:

2、看一下抓包,可以看到,数据是通过 三层 vni 1000 传递的:

3、看一下 PE1 的实例路由,可以看到,因为有了 IRB 路由,对端 PE 的路由通过 BGP EVPN Type 2 mac-route 传递到了三层实例路由表中:

四、详细配置:

NE1(PE1):

evpn vpn-instance 1 bd-mode

route-distinguisher 1:1

vpn-target 1:1 export-extcommunity

vpn-target 1:1 import-extcommunity

evpn vpn-instance 2 bd-mode

route-distinguisher 2:2

vpn-target 2:2 export-extcommunity

vpn-target 2:2 import-extcommunity

ip vpn-instance 1

ipv4-family

route-distinguisher 11:11

vpn-target 11:11 export-extcommunity evpn

vpn-target 22:22 import-extcommunity evpn

vpn-target 2:2 import-extcommunity evpn #这里要把 evpn 实例2 的target 配到 三层实例中,因为 evpn 路由只在二层运行

vxlan vni 1000

bridge-domain 100

vxlan vni 100 split-horizon-mode

evpn binding vpn-instance 1

bridge-domain 200

vxlan vni 200 split-horizon-mode

evpn binding vpn-instance 2

interface Vbdif100

ip binding vpn-instance 1

ip address 10.1.1.254 255.255.255.0

arp collect host enable

interface Ethernet1/0/0

undo shutdown

undo dcn

undo dcn mode vlan

interface Ethernet1/0/0.10 mode l2

encapsulation dot1q vid 10

rewrite pop single

bridge-domain 100

interface Ethernet1/0/0.20 mode l2

encapsulation dot1q vid 20

rewrite pop single

bridge-domain 200

interface Ethernet1/0/1

undo shutdown

ip address 13.1.1.1 255.255.255.0

undo dcn

undo dcn mode vlan

interface LoopBack0

ip address 1.1.1.1 255.255.255.255

interface Nve1

source 1.1.1.1

vni 100 head-end peer-list protocol bgp

vni 200 head-end peer-list protocol bgp

bgp 100

router-id 1.1.1.1

undo default ipv4-unicast

peer 2.2.2.2 as-number 100

peer 2.2.2.2 connect-interface LoopBack0

ipv4-family unicast

undo synchronization

undo peer 2.2.2.2 enable

ipv4-family vpn-instance 1

advertise l2vpn evpn

l2vpn-family evpn

undo policy vpn-target

peer 2.2.2.2 enable

peer 2.2.2.2 advertise irb

peer 2.2.2.2 advertise encap-type vxlan

ospf 1 router-id 1.1.1.1

area 0.0.0.0

network 1.1.1.1 0.0.0.0

network 13.1.1.0 0.0.0.255

undo dcn

AR1(P):

复制代码
interface GigabitEthernet0/0/0
 ip address 13.1.1.3 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 23.1.1.3 255.255.255.0 
#
interface LoopBack0
 ip address 3.3.3.3 255.255.255.255 
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 3.3.3.3 0.0.0.0 
  network 13.1.1.0 0.0.0.255 
  network 23.1.1.0 0.0.0.255 
  #

NE2(PE2):

复制代码
evpn vpn-instance 1 bd-mode
 route-distinguisher 3:3
 vpn-target 1:1 export-extcommunity
 vpn-target 1:1 import-extcommunity
#
evpn vpn-instance 2 bd-mode
 route-distinguisher 4:4
 vpn-target 2:2 export-extcommunity
 vpn-target 2:2 import-extcommunity
#
ip vpn-instance 1
 ipv4-family
  route-distinguisher 22:22
  vpn-target 22:22 export-extcommunity evpn
  vpn-target 11:11 import-extcommunity evpn
  vpn-target 1:1 import-extcommunity evpn
 vxlan vni 1000
#
bridge-domain 100
 vxlan vni 100 split-horizon-mode
 evpn binding vpn-instance 1
#
bridge-domain 200
 vxlan vni 200 split-horizon-mode
 evpn binding vpn-instance 2
#
interface Vbdif200
 ip binding vpn-instance 1
 ip address 10.2.2.254 255.255.255.0
 arp collect host enable
#
interface Ethernet1/0/0
 undo shutdown
 undo dcn
 undo dcn mode vlan
#
interface Ethernet1/0/0.10 mode l2
 encapsulation dot1q vid 10
 rewrite pop single
 bridge-domain 100
#
interface Ethernet1/0/0.20 mode l2
 encapsulation dot1q vid 20
 rewrite pop single
 bridge-domain 200
#
interface Ethernet1/0/1
 undo shutdown
 ip address 23.1.1.2 255.255.255.0
 undo dcn
 undo dcn mode vlan
#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.255
#
interface Nve1
 source 2.2.2.2
 vni 5000 head-end peer-list protocol bgp
 vni 5001 head-end peer-list protocol bgp
#
bgp 100
 router-id 2.2.2.2
 undo default ipv4-unicast
 peer 1.1.1.1 as-number 100
 peer 1.1.1.1 connect-interface LoopBack0
 #
 ipv4-family unicast
  undo synchronization
  undo peer 1.1.1.1 enable
 #
 ipv4-family vpn-instance 1
  advertise l2vpn evpn
 #
 l2vpn-family evpn
  undo policy vpn-target
  peer 1.1.1.1 enable
  peer 1.1.1.1 advertise irb
  peer 1.1.1.1 advertise encap-type vxlan
#
ospf 1 router-id 2.2.2.2
 area 0.0.0.0
  network 2.2.2.2 0.0.0.0
  network 23.1.1.0 0.0.0.255
#
undo dcn
#

五、总结:

和方式1 直接宣告网关路由的方式不同,方式2 需要在三层实例路由中开启宣告 L2vpn evpn 能力,并且在 L2vpn evpn 地址族中开启宣告 irb 路由,并且,还需要在三层 IP实例下,配置 evpn 模式的 vpn-target,并打开对端二层 evpn 的 vpn-target 出向值,才能收到对端的 IRB路由

ensp 中,由于用的是NE5000E的设备,无法做分布式网关,只能测一下 EVPN 的 Type 2 三层互通的情况,需要用 CE12800

另外:如果有三层实例,那么需要在和CE的二层接口上弹出tag,如果仅是二层,在二层接口上弹出vlan tag,则无法通信,并且二层 vxlan vni 都是 down 的,这是因为二层和三层通信方式的不同,三层不需要 vlan tag,而二层需要带上vlan tag 才能进行互通

六、踩过的坑:

配置完成后,用 PC1 ping PC4,发现不通,于是查了一下 mac-route,发现 mac-route 里的路由都没有 IP 地址,仔细检查,发现网关上没有开启主机路由收集功能,未开时是这样的:

开启后是这样的:

七、最后再附一张 IRB 路由的三种形式的图:

相关推荐
乘云数字DATABUFF3 天前
5分钟部署开源APM Databuff:OpenTelemetry全链路追踪入门实战
运维·后端
荣--5 天前
一键部署不是为了省时间 —— 它是把"买来的 PaaS"变成"自己的平台"的拐点
运维·zabbix·工程化·一键部署·平台化·边界设计
江华森5 天前
动手实战学 Docker — 从零到集群编排完全指南
运维
Avan_菜菜6 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
SelectDB7 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
XIAOHEZIcode8 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220709 天前
如何搭建本地yum源(上)
运维
大树8812 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠12 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质12 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务