BGP MPLS L3VPN原理及实践
【摘要】 使用场景在运营商骨干网络上提供L3VPN业务,利用BGP协议发布路由信息,在骨干网内部使用MPLS转发VPN报文。概念CE(Consumer Edge):用户边缘路由器,与运营商网络直接相连的路由器。感知不到VPN的存在,一个CE设备只能对应一个VPN主要功能就是将VPN客户的路由通告给PE,以及从PE学习同一个VPN下其他站点的路由PE(Provider Edge):运行商(骨干网)边缘路...
使用场景
在运营商骨干网络上提供L3VPN业务,利用BGP协议发布路由信息,在骨干网内部使用MPLS转发VPN报文。
概念
CE(Consumer Edge):用户边缘路由器,与运营商网络直接相连的路由器。
感知不到VPN的存在,一个CE设备只能对应一个VPN
主要功能就是将VPN客户的路由通告给PE,以及从PE学习同一个VPN下其他站点的路由
PE(Provider Edge):运行商(骨干网)边缘路由器,与用户网络相连的路由器。
负责VPN业务接入,处理VPN-IPV4路由
使用VRF对VPN客户进行隔离
通过与客户设备CE进行路由协议,以便获取客户路由,并将路由生成VPNv4前缀放入MPLS VPN骨干网传递到对端PE
P(Provider):骨干网路由器,与PE或其他P相连。
负责快速转发数据
不知道VPN客户网络,以及客户的路由。只负责在骨干网内运载标签数据
VRF(Virtual Router Forwarding):PE上的虚拟路由器(路由进程)。
一张独立的路由表,包括独立的地址空间
一组归属于这个VRF的接口的集合,
一组只用于本VRF的路由协议
一个VPN对应一个VRF
RD(Route-Distinguisher):路由标识符
BGP进程用该字段区分不同VPN,有了RD后就可以解决不同VPN之间的IP地址重叠问题,VPN用户的IP地址不再是整个系统全局唯一,而是VPN内唯一即可。
长度:8字节
RD有两种格式:
16位自治系统号:32位用户自定义数
,例如:101:3。自治系统号的取值范围是0~65535;用户自定义数的取值范围是0~4294967295。其中,自治系统号和用户自定义数不能同时为0,即RD的值不能是0:0。32位IP地址:16位用户自定义数
,例如:192.168.122.15:1。IP地址的取值范围是0.0.0.0~255.255.255.255;用户自定义数的取值范围是0~65535。
RT(Route-Target)
每个VRF表达自己的路由输出和输出方式,主要用于控制VPN路由的发布和安装策略。
属性:
import 声明当前VPN接受的路由属性
export 声明当前VPN发出的路由属性
对端PE接收路由时,首先接收所有的路由,并根据每个VRF配置的RT.import规则进行检查,如果与路由中的RT属性匹配,则将该路由加入到相应的VRF中。
RT和RD有着同样的结构,为什么不用RD来区分VPN(即用RD实现RT功能)?
分开定义有分开定义的灵活性。
当一条路由需要传递到多个VPN时,如果没有RT,就需要创建多条BGP数据,每条有着不同的RD。而有RT的话,只需要创建一条BGP数据,带上多个RT即可。从数据的长短来看,后者更有优势。
原理
MPLS VPN主要采用的技术及其解决的问题:
MPLS隧道技术:隧道的动态建立
多VRF技术:本地地址冲突
MP-BGP技术:VPN私网路由学习
PE之间,是通过MPLSTunnel(LSP)通讯的,是通过MP-BGP协议传递路由信息。MPLSTunnel则是承载在P上。
CE-PE之间,是两个普通路由器之间的交流,可以是IGP,如:OSPF,EIGRP,可以是BGP,也可以配置静态路由。
实验
组网
路由器
序号 | 设备 | Router-ID | 换回接口 | IP地址 |
---|---|---|---|---|
1 | PE1 | 1.1.1.1 | Loopback0 | 1.1.1.1 |
2 | PE2 | 2.2.2.2 | Loopback0 | 2.2.2.2 |
3 | P1 | 3.3.3.3 | Loopback0 | 3.3.3.3 |
4 | P2 | 4.4.4.4 | Loopback0 | 4.4.4.4 |
VPN实例
序号 | 实例名 | RD | RT |
---|---|---|---|
1 | vpn1 | 100:1 | 100:1 |
2 | vpn2 | 200:1 | 200:1 |
其他
各个接口的IP地址规划请见组网图。
配置
PE1配置
#
ip vpn-instance vpn1
ipv4-family
route-distinguisher 100:1
vpn-target 100:1 export-extcommunity
vpn-target 100:1 import-extcommunity
#
ip vpn-instance vpn2
ipv4-family
route-distinguisher 200:1
vpn-target 200:1 export-extcommunity
vpn-target 200:1 import-extcommunity
#
mpls lsr-id 1.1.1.1
mpls
label advertise non-null
#
mpls ldp
#
#
interface GigabitEthernet0/0/0
ip address 10.0.13.1 255.255.255.252
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip binding vpn-instance vpn1
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip binding vpn-instance vpn2
ip address 192.168.2.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
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 vpnv4
policy vpn-target
peer 2.2.2.2 enable
#
ipv4-family vpn-instance vpn1
import-route direct
#
ipv4-family vpn-instance vpn2
import-route direct
#
ospf 1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 10.0.13.0 0.0.0.3
PE2配置
#
ip vpn-instance vpn1
ipv4-family
route-distinguisher 100:1
vpn-target 100:1 export-extcommunity
vpn-target 100:1 import-extcommunity
#
ip vpn-instance vpn2
ipv4-family
route-distinguisher 200:1
vpn-target 200:1 export-extcommunity
vpn-target 200:1 import-extcommunity
#
mpls lsr-id 2.2.2.2
mpls
label advertise non-null
#
mpls ldp
#
#
interface GigabitEthernet0/0/0
ip address 10.0.24.1 255.255.255.252
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip binding vpn-instance vpn1
ip address 192.168.3.1 255.255.255.0
#
interface GigabitEthernet0/0/2
ip binding vpn-instance vpn2
ip address 192.168.4.1 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
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 vpnv4
policy vpn-target
peer 1.1.1.1 enable
#
ipv4-family vpn-instance vpn1
import-route direct
#
ipv4-family vpn-instance vpn2
import-route direct
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 10.0.24.0 0.0.0.3
P1配置
#
mpls lsr-id 3.3.3.3
mpls
label advertise non-null
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 10.0.13.2 255.255.255.252
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 10.0.34.1 255.255.255.252
mpls
mpls ldp
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
ospf 1
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 10.0.13.0 0.0.0.3
network 10.0.34.0 0.0.0.3
P2配置
#
mpls lsr-id 4.4.4.4
mpls
label advertise non-null
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 10.0.24.2 255.255.255.252
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 10.0.34.2 255.255.255.252
mpls
mpls ldp
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
ospf 1
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 10.0.24.0 0.0.0.3
network 10.0.34.0 0.0.0.3
连通性测试
PC1 ping PC3
PC2 ping PC4
PC1 ping PC2&PC4 —- 不同VPN,不通
分析
VPN路由表
# vpn1路由表
<Huawei>dis ip routing-table vpn-instance vpn1
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: vpn1
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.1.0/24 Direct 0 0 D 192.168.1.1 GigabitEthernet0/0/1
192.168.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
192.168.3.0/24 IBGP 255 0 RD 2.2.2.2 GigabitEthernet0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
#vpn2路由表
<Huawei>dis ip routing-table vpn-instance vpn2
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: vpn2
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.2.0/24 Direct 0 0 D 192.168.2.1 GigabitEthernet0/0/2
192.168.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/2
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/2
192.168.4.0/24 IBGP 255 0 RD 2.2.2.2 GigabitEthernet0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
查看BGP邻居
[Huawei-bgp]display bgp vpnv4 all peer
BGP local router ID : 1.1.1.1
Local AS number : 100
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
2.2.2.2 4 100 4 5 0 00:00:09 Established 2
BGP路由通告数据包
在PE1和P1之间抓包:
数据面数据包
PC1 ping PC3,同时在PE1和P1之间抓包:
在骨干网内通过MPLS协议转发VPN数据包(ICMP报文)。
PE1上查看MPLS LSP
<Huawei>dis mpls lsp
-------------------------------------------------------------------------------
LSP Information: BGP LSP
-------------------------------------------------------------------------------
FEC In/Out Label In/Out IF Vrf Name
192.168.1.0/24 1031/NULL -/- vpn1
192.168.2.0/24 1032/NULL -/- vpn2
-------------------------------------------------------------------------------
LSP Information: LDP LSP
-------------------------------------------------------------------------------
FEC In/Out Label In/Out IF Vrf Name
2.2.2.2/32 NULL/1028 -/GE0/0/0
2.2.2.2/32 1033/1028 -/GE0/0/0
3.3.3.3/32 NULL/1024 -/GE0/0/0
3.3.3.3/32 1034/1024 -/GE0/0/0
4.4.4.4/32 NULL/1027 -/GE0/0/0
4.4.4.4/32 1035/1027 -/GE0/0/0
1.1.1.1/32 1036/NULL -/-
说明:
实验使用eNSP仿真软件进行,路由器型号为AR3260。
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)