1.MPLS VPN概述
(1)MPLS VPN定义

(2)MPLS VPN网络架构

CE:用户网络边缘设备,有接口直接与运营商网络相连。CE可以是路由器或交换机,也可以是一台主机。通常情况下,CE"感知"不到VPN的存在,也不需要支持MPLS。
PE:运营商边缘路由器,是运营商网络的边缘设备,与CE直接相连。在MPLS网络中,对VPN的所有处理都发生在PE上,对PE性能要求较高。
P:运营商网络中的骨干路由器,不与CE直接相连。P设备只需要具备基本MPLS转发能力,不维护VPN相关信息。
站点的含义可以从下述几个方面理解:
站点是指相互之间具备IP连通性的一组IP系统,并且这组IP系统的IP连通性不需通过运营商网络实现。
站点的划分是根据设备的拓扑关系,而不是地理位置。如图所示,公司A的X省网络和公司A的Y省网络需要通过运营商的骨干网进行互联,所以它们被划分为两个站点。若在当前X省网络和Y省网络的CE之间增加一条物理专线,不需要通过运营商网络就可以互通,那么这两张网络就是一个站点。
站点与VPN的关系:
对于多个连接到同一服务提供商网络的站点,通过制定策略,可以将它们划分为不同的集合,只有属于相同集合的站点之间才能通过服务提供商网络互访,这种集合就是VPN。
一个Site中的设备可以属于多个VPN,换言之,一个Site可以属于多个VPN。
注:也有可能出现站点为一台主机的情况,此时该主机就是CE设备。本课程仅讨论站点是一个或多个子网,用路由器或交换机作为CE的情况。
2.MPLS VPN路由交互
(1)MPLS VPN 路由发布概述

(2)CE与PE之间的路由信息交换

(3)入口PE到出口PE路由传递(1)

(4)VRF

(5)RD

(6)VPN-IPv4地址

(7)MP-BGP

(8)入口PE到出口PE路由传递(3)

(9)RT

(10)入口PE到出口PE路由传递(4)

(11)数据转发时遇到的问题

(12)通过标签解决问题

(13)入口PE到出口PE路由传递(5)

PE上分配私网标签的方法有如下两种:
基于路由的MPLS标签分配:为VPN路由表的每一条路由分配一个标签(one label per route)。这种方式的缺点是:当路由数量比较多时,设备入标签映射表ILM(Incoming Label Map)需要维护的表项也会增多,从而提高了对设备容量的要求。
基于VPN实例的MPLS标签分配:为整个VPN实例分配一个标签,该VPN实例里的所有路由都共享一个标签。使用这种分配方法的好处是节约了标签。
私网路由交叉:VPNv4路由与本地VPN实例的VPN-Target进行匹配的过程称为私网路由交叉。PE在收到VPNv4路由后,既不进行优选,也不检查隧道是否存在,直接将其与本地的VPN实例进行交叉。
隧道迭代:为了将私网流量通过公网传递到另一端,需要有一条公网隧道承载这个私网流量。因此私网路由交叉完成后,需要根据目的IPv4前缀进行路由迭代,即该IPv4路由的下一跳有对应的LSP存在;只有隧道迭代成功,该路由才被放入对应的VPN实例路由表。
(14)MPLS VPN中的路由交互全过程

3.MPLS VPN报文转发
(1)报文转发过程(1)

(2)报文转发过程(2)

(3)报文转发过程(3)

(4)报文转发过程(4)


4.MPLS VPN报文转发
(1)配置命令-VPN实例配置(1)

(2)配置命令-VPN实例配置(2)

(3)配置命令-MP-BGP配置

(4)配置命令-PE与CE间路由配置

(5)MPLS VPN案例
A公司总部和PE之间才用OSPF交互路由信息,A公司分部和PE之间才用BGP交互路由信息,B公司总部和PE之间才用静态路由交互路由信息,B公司分部和PE之间才用ISIS交互路由信息。

A-zongbuospf 1
A-zongbu-ospf-1area 0
A-zongbu-ospf-1-area-0.0.0.0network 192.168.8.8 0.0.0.0
A-zongbu-ospf-1-area-0.0.0.0network 201.1.1.8 0.0.0.0
AR1ip vpn-instance A
AR1-vpn-instance-Aroute-distinguisher 11:11
AR1inter g0/0/1
AR1-GigabitEthernet0/0/1ip binding vpn-instance A
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
AR1-GigabitEthernet0/0/1ip add 201.1.1.1 24
AR1ospf 2 vp
AR1ospf 2 vpn-instance A
AR1-ospf-2-area-0.0.0.0network 201.1.1.1 0.0.0.0
AR3ip vpn-instance A
AR3-vpn-instance-Aroute-distinguisher 22:22
AR3inter g0/0/0
AR3-GigabitEthernet0/0/0ip binding vpn-instance A
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
AR3-GigabitEthernet0/0/0ip add 202.1.1.1 24
AR3bgp 123
AR3-bgpipv4-family vpn-instance A
AR3-bgp-Apeer 202.1.1.9 as-number 65888
A-fenbubgp 65888
A-fenbu-bgppeer 202.1.1.1 as-number 123
BGP除了ipv4 地址族默认激活外,其他的都是没有激活的
AR3-bgpipv4-family vpn-instance A
A-fenbu-bgpnetwork 192.168.9.8 32
AR3dis ip routing-table vpn-instance A (查看是否学到A公司分部的BGP路由)

AR1mpls lsr-id 10.0.1.1
AR1mpls
AR1-mplsq
AR1mpl ldp
AR1inter g0/0/0
AR1-GigabitEthernet0/0/0mpls
AR1-GigabitEthernet0/0/0mpls ldp
AR2mpls lsr-id 10.0.2.2
AR2mpls
AR2-mplsq
AR2mpls ldp
AR2-mpls-ldpq
AR2inter g0/0/0
AR2-GigabitEthernet0/0/0mpls ldp
AR2inter g0/0/1
AR2-GigabitEthernet0/0/1mpls
AR2-GigabitEthernet0/0/1mpls ldp
AR3mpls lsr-id 10.0.3.3
AR3mpls
AR3mpls ldp
AR3-mpls-ldpq
AR3inter g0/0/1
AR3-GigabitEthernet0/0/1mpls
AR3-GigabitEthernet0/0/1mpls ldp
查看会话是否正常:
AR2dis mpls ldp session all
查看有没有发标签:
AR2dis mpls lsp

AR1ip vpn-instance A
AR1-vpn-instance-Avpn-target 100:1 import-extcommunity
AR1-vpn-instance-Avpn-target 100:1 export-extcommunity
AR3ip vpn-instance A
AR3-vpn-instance-Avpn-target 100:1 (标识导入导出的流量)
IVT Assignment result:
Info: VPN-Target assignment is successful.
EVT Assignment result:
Info: VPN-Target assignment is successful.
AR1bgp 123
AR1-bgppeer 10.0.3.3 as-number 123
AR1-bgppeer 10.0.3.3 c l 0
AR1-bgppeer 10.0.3.3 next-hop-local (对方下一跳的值为我本身)
AR1-bgpipv4-family vpnv4
AR1-bgp-af-vpnv4peer 10.0.3.3 enable (启用VPNV4让路由器可以传递VPNV4路由)
AR3bgp 123
AR3-bgppeer 10.0.1.1 as 123
AR3-bgppeer 10.0.1.1 c l 0
AR3-bgppeer 10.0.1.1 next-hop-local
AR3-bgpipv4-family vpnv4
AR3-bgp-af-vpnv4peer 10.0.1.1 enable
AR1dis bgp vpnv4 all peer(查看邻居是否正常)

AR1bgp 123
AR1-bgpipv4-family vpn-instance A
AR1-bgp-Aimport-route ospf 2
AR1-bgpdis bgp vpnv4 vpn-instance A routing-table (查看路由实例)

AR1ospf 2
AR1-ospf-2im
AR1-ospf-2import-route bgp
B-fenbuip route-static 0.0.0.0 0.0.0.0 204.1.1.1
AR1ip vpn-instance B
AR1-vpn-instance-Bro
AR1-vpn-instance-Broute-distinguisher 33:33
AR1-vpn-instance-B-af-ipv4vp
AR1-vpn-instance-B-af-ipv4vpn-target 200:1
AR1-GigabitEthernet0/0/2ip binding vpn-instance B
AR1-GigabitEthernet0/0/2ip add 204.1.1.1 24
AR1ip route-static vpn-instance B 192.168.8.0 24 204.1.1.8
AR1bgp 123
AR1-bgpipv4-family vpn-instance B
AR1-bgp-Bimport-route static
AR3ip vpn-instance B
AR3-vpn-instance-Broute-distinguisher 44:44
AR3-vpn-instance-B-af-ipv4vpn-target 200:1
AR3-GigabitEthernet0/0/2ip binding vpn-instance B
Info: All IPv4 related configurations on this interface are removed!
Info: All IPv6 related configurations on this interface are removed!
AR3-GigabitEthernet0/0/2IP ADD 203.1.1.1 24
AR3ISIS vpn-instance B
AR3-isis-1network-entity 49.0001.0000.0000.0001.00
AR3-isis-1inter g0/0/2
AR3-GigabitEthernet0/0/2isis enable 1
B-zongbuisis 1
B-zongbu-isis-1network-entity 49.0001.0000.0000.0002.00.
B-zongbuinter g0/0/0
B-zongbu-GigabitEthernet0/0/0isis enable 1
B-zongbu-LoopBack9isi enable 1
AR3dis isis peer vpn-instance B

AR3isis
AR3-isis-1im
AR3-isis-1import-route bgp
AR3-bgpipv4-family vpn-instance B
AR3-bgp-Bimport-route isis 1
查看vpn实例:
dis IP v v

