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-zongbu\]ospf 1 \[A-zongbu-ospf-1\]area 0 \[A-zongbu-ospf-1-area-0.0.0.0\]network 192.168.8.8 0.0.0.0 \[A-zongbu-ospf-1-area-0.0.0.0\]network 201.1.1.8 0.0.0.0 \[AR1\]ip vpn-instance A \[AR1-vpn-instance-A\]route-distinguisher 11:11 \[AR1\]inter g0/0/1 \[AR1-GigabitEthernet0/0/1\]ip 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/1\]ip add 201.1.1.1 24 \[AR1\]ospf 2 vp \[AR1\]ospf 2 vpn-instance A \[AR1-ospf-2-area-0.0.0.0\]network 201.1.1.1 0.0.0.0 \[AR3\]ip vpn-instance A \[AR3-vpn-instance-A\]route-distinguisher 22:22 \[AR3\]inter g0/0/0 \[AR3-GigabitEthernet0/0/0\]ip 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/0\]ip add 202.1.1.1 24 \[AR3\]bgp 123 \[AR3-bgp\]ipv4-family vpn-instance A \[AR3-bgp-A\]peer 202.1.1.9 as-number 65888 \[A-fenbu\]bgp 65888 \[A-fenbu-bgp\]peer 202.1.1.1 as-number 123 BGP除了ipv4 地址族默认激活外,其他的都是没有激活的 \[AR3-bgp\]ipv4-family vpn-instance A \[A-fenbu-bgp\]network 192.168.9.8 32 \[AR3\]dis ip routing-table vpn-instance A (查看是否学到A公司分部的BGP路由)  \[AR1\]mpls lsr-id 10.0.1.1 \[AR1\]mpls \[AR1-mpls\]q \[AR1\]mpl ldp \[AR1\]inter g0/0/0 \[AR1-GigabitEthernet0/0/0\]mpls \[AR1-GigabitEthernet0/0/0\]mpls ldp \[AR2\]mpls lsr-id 10.0.2.2 \[AR2\]mpls \[AR2-mpls\]q \[AR2\]mpls ldp \[AR2-mpls-ldp\]q \[AR2\]inter g0/0/0 \[AR2-GigabitEthernet0/0/0\]mpls ldp \[AR2\]inter g0/0/1 \[AR2-GigabitEthernet0/0/1\]mpls \[AR2-GigabitEthernet0/0/1\]mpls ldp \[AR3\]mpls lsr-id 10.0.3.3 \[AR3\]mpls \[AR3\]mpls ldp \[AR3-mpls-ldp\]q \[AR3\]inter g0/0/1 \[AR3-GigabitEthernet0/0/1\]mpls \[AR3-GigabitEthernet0/0/1\]mpls ldp 查看会话是否正常: \[AR2\]dis mpls ldp session all 查看有没有发标签: \[AR2\]dis mpls lsp  \[AR1\]ip vpn-instance A \[AR1-vpn-instance-A\]vpn-target 100:1 import-extcommunity \[AR1-vpn-instance-A\]vpn-target 100:1 export-extcommunity \[AR3\]ip vpn-instance A \[AR3-vpn-instance-A\]vpn-target 100:1 (标识导入导出的流量) IVT Assignment result: Info: VPN-Target assignment is successful. EVT Assignment result: Info: VPN-Target assignment is successful. \[AR1\]bgp 123 \[AR1-bgp\]peer 10.0.3.3 as-number 123 \[AR1-bgp\]peer 10.0.3.3 c l 0 \[AR1-bgp\]peer 10.0.3.3 next-hop-local (对方下一跳的值为我本身) \[AR1-bgp\]ipv4-family vpnv4 \[AR1-bgp-af-vpnv4\]peer 10.0.3.3 enable (启用VPNV4让路由器可以传递VPNV4路由) \[AR3\]bgp 123 \[AR3-bgp\]peer 10.0.1.1 as 123 \[AR3-bgp\]peer 10.0.1.1 c l 0 \[AR3-bgp\]peer 10.0.1.1 next-hop-local \[AR3-bgp\]ipv4-family vpnv4 \[AR3-bgp-af-vpnv4\]peer 10.0.1.1 enable \[AR1\]dis bgp vpnv4 all peer(查看邻居是否正常)  \[AR1\]bgp 123 \[AR1-bgp\]ipv4-family vpn-instance A \[AR1-bgp-A\]import-route ospf 2 \[AR1-bgp\]dis bgp vpnv4 vpn-instance A routing-table (查看路由实例)  \[AR1\]ospf 2 \[AR1-ospf-2\]im \[AR1-ospf-2\]import-route bgp \[B-fenbu\]ip route-static 0.0.0.0 0.0.0.0 204.1.1.1 \[AR1\]ip vpn-instance B \[AR1-vpn-instance-B\]ro \[AR1-vpn-instance-B\]route-distinguisher 33:33 \[AR1-vpn-instance-B-af-ipv4\]vp \[AR1-vpn-instance-B-af-ipv4\]vpn-target 200:1 \[AR1-GigabitEthernet0/0/2\]ip binding vpn-instance B \[AR1-GigabitEthernet0/0/2\]ip add 204.1.1.1 24 \[AR1\]ip route-static vpn-instance B 192.168.8.0 24 204.1.1.8 \[AR1\]bgp 123 \[AR1-bgp\]ipv4-family vpn-instance B \[AR1-bgp-B\]import-route static \[AR3\]ip vpn-instance B \[AR3-vpn-instance-B\]route-distinguisher 44:44 \[AR3-vpn-instance-B-af-ipv4\]vpn-target 200:1 \[AR3-GigabitEthernet0/0/2\]ip 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/2\]IP ADD 203.1.1.1 24 \[AR3\]ISIS vpn-instance B \[AR3-isis-1\]network-entity 49.0001.0000.0000.0001.00 \[AR3-isis-1\]inter g0/0/2 \[AR3-GigabitEthernet0/0/2\]isis enable 1 \[B-zongbu\]isis 1 \[B-zongbu-isis-1\]network-entity 49.0001.0000.0000.0002.00. \[B-zongbu\]inter g0/0/0 \[B-zongbu-GigabitEthernet0/0/0\]isis enable 1 \[B-zongbu-LoopBack9\]isi enable 1 \[AR3\]dis isis peer vpn-instance B  \[AR3\]isis \[AR3-isis-1\]im \[AR3-isis-1\]import-route bgp \[AR3-bgp\]ipv4-family vpn-instance B \[AR3-bgp-B\]import-route isis 1 查看vpn实例: dis IP v v  