简介
本文档介绍如何配置基本多协议标签交换 (MPLS) VPN 核心网络。
先决条件
要求
Cisco 建议您了解以下主题:
- 基本IP路由知识
- 了解Cisco IOS®命令行界面(CLI)
使用的组件
本文档中的信息基于以下软件和硬件版本:
P 和 PE 路由器
C 和 CE 路由器
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
规则
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
以下字母代表所使用的不同类型的路由器和交换机:
-
P — 提供商路由器
-
PE —供应商边缘路由器
-
CE —边缘路由器Customer
-
C —路由器Customer
注意:PE路由器是提供商网络中的最后一跳。这些设备直接连接到CE路由器,CE路由器是客户拥有的设备,与服务提供商网络进行接口但不参与MPLS操作。
背景信息
MPLS是一种高性能网络技术,它使用短路径标签而不是长网络地址将数据从一个节点定向到另一个节点。
此方法可加速和整形企业和服务提供商网络之间的流量。
MPLS为数据包分配标签,标签交换路由器(LSR)或P路由器使用该标签来做出转发决策。
在网络边缘的边缘路由器(LER)或PE路由器添加和删除这些标签。
MPLS使用转发等价类(FEC)对以相同方式转发的数据包进行分组,并使用标签分发协议(LDP)在路由器之间分发标签映射。
这可确保整个网络中标签绑定的视图保持一致。
MPLS的优势包括提高的性能、可扩展性、流量工程能力,以及对服务质量(QoS)的支持。
它不受协议限制,因此是适合各种网络环境的通用解决方案。
MPLS广泛用于创建可扩展且安全的虚拟专用网络(VPN)、管理和优化流量流,并支持将不同类型的流量(例如数据、语音和视频)融合到单个网络基础设施中。
本文档提供MPLS VPN网络的示例配置,其中边界网关协议(BGP)在提供商边缘(PE)和CE客户边缘(CE)路由器之间使用。
与 MPLS 一起使用时,VPN 功能允许多个站点通过运营商网络透明地互连。
一个服务提供商网络可以支持多个不同的IP VPN,每个IP VPN对用户显示为独立于所有其他网络的专用网络。
在一个 VPN 内,每个站点都可以向该 VPN 的其他任何站点发送 IP 数据包。
每个 VPN 都与一个或多个虚拟路由和转发 (VRF) 实例相关联。一个 VRF 由一个 IP 路由表、一个派生的 Cisco 快速转发 (CEF) 表和使用此转发表的一组接口组成。
路由器为每个 VRF 维护单独的路由信息库 (RIB) 和 CEF 表。这可确保信息不会发送到VPN外部,从而允许在多个VPN中使用同一子网,而不会导致重复IP地址问题。
使用多协议 BGP (MP-BGP) 的路由器通过 MP-BGP 扩展社区分发 VPN 路由信息。
配置
此部分提供配置示例及其实施方式。
网络图
本文档使用此网络设置,此图显示一个典型配置,说明前面介绍的约定:
MPLS拓扑
MPLS配置过程
在核心网络中配置MPLS
1.验证在需要MPLS的路由器上启用了ip cef(在最新的软件版本上默认启用CEF)。
2.在服务提供商核心上配置内部网关协议(IGP),建议选择开放最短路径优先(OSPF)或中间系统到中间系统(IS-IS)协议,并从每个P和PE路由器通告Loopback0。
3.服务提供商核心路由器在其环回之间完全可访问第3层(L3)后,在P和PE路由器之间的每个L3接口上配置命令mpls ip,或使用mpls ldp autoconfig命令在运行OSPF或IS-IS进程的每个接口上启用LDP。
注意:直接连接到CE路由器的PE路由器接口不需要mpls ip命令配置。
将mpls ip配置添加到接口后,在PE路由器上完成以下步骤:
4.为使用命令连接的每个VPN创建一个 vrf definition VRF。额外步骤:
指定用于该 VPN 的路由标识符。命令 用于扩展 IP 地址,以便您可以识别它属于哪个 VPN。 rd
vrf definition Client_A
rd 100:110
设置 MP-BGP 扩展团体的导入和导出属性。这些命令用于使用route-target {import|export|both} <target VPN extended community>命令过滤导入和导出进程,如下面的输出所示:
vrf definition Client_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
address-family ipv4
exit-address-family
5.在PE路由器上,添加将CE连接到相应VRF的接口。使用vrf forwarding命令配置各个接口的转发详细信息并设置IP地址。
PE-1#show run interface GigabitEthernet0/1
Building configuration...
Current configuration : 138 bytes
!
interface GigabitEthernet0/1
vrf forwarding Client_A
ip address 10.0.4.2 255.255.255.0
duplex auto
speed auto
media-type rj45
end
配置 MP-BGP
配置 BGP 的方法有多种,例如,可以将 PE 路由器配置为 BGP 邻居,或者使用路由反射器 (RR) 或联盟方法。下一个示例中使用路由反射器,它比PE路由器之间使用全网状邻居时更具可扩展性:
1.为此PE路由器上的每个VPN输入address-family ipv4 vrf <VRF name> 命令。接下来,根据需要执行下面的一个或多个步骤:
注意:根据您使用的PE-CE路由协议,您可以在PE和CE设备之间配置任何动态路由协议(EIGRP、OSPF或BGP)。如果 BGP 是用于在 PE 和 CE 之间交换路由信息的协议,则无需配置协议之间的重新分发。
2.在路由器bgp层次结构下,输入address-family vpnv4模式,并完成以下步骤:
配置
本文档使用以下配置来设置 MPLS VPN 网络示例:
| PE-1 |
hostname PE-1
!
ip cef
!
!--- VPN Client_A commands.
vrf definition Client_A
rd 100:110
route-target export 100:1000
route-target import 100:1000 !
address-family ipv4
exit-address-family
!--- Enables the VPN routing and forwarding (VRF) routing table. !--- Route distinguisher creates routing and forwarding tables for a VRF. !--- Route targets creates lists of import and export extended communities for the specified VRF.
!--- VPN Client_B commands.
vrf definition Client_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
address-family ipv4
exit-address-family ! interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis !
interface GigabitEthernet0/1
vrf forwarding Client_A
ip address 10.0.4.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
vrf forwarding Client_B
ip address 10.0.4.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!--- Associates a VRF instance with an interface or subinterface. !--- GigabitEthernet0/1 and 0/2 use the same IP address, 10.0.4.2. !--- This is allowed because they belong to two different customer VRFs.
! interface GigabitEthernet0/0
description link to P-1
ip address 10.1.1.14 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!--- Enables MPLS on the L3 interface connecting to the P router
! router isis
net 49.0001.0000.0000.0004.00
is-type level-2-only
metric-style wide
passive-interface Loopback0
!--- Enables IS-IS as the IGP in the provider core network
!
router bgp 65000
bgp log-neighbor-changes neighbor 10.10.10.2 remote-as 65000 neighbor 10.10.10.2 update-source Loopback0
!--- Adds an entry to the BGP or MP-BGP neighbor table. !--- And enables BGP sessions to use a specific operational interface for TCP connections.
!
address-family vpnv4
neighbor 10.10.10.2 activate
neighbor 10.10.10.2 send-community both
exit-address-family
!--- To enter address family configuration mode that use standard VPN version 4 address prefixes. !--- Creates the VPNv4 neighbor session to the Route Reflector. !--- And to send the community attribute to the BGP neighbor. !
address-family ipv4 vrf Client_A
neighbor 10.0.4.1 remote-as 65002
neighbor 10.0.4.1 activate
exit-address-family
!
address-family ipv4 vrf Client_B
neighbor 10.0.4.1 remote-as 65001
neighbor 10.0.4.1 activate
exit-address-family
!--- These are the eBGP sessions to each CE router belonging to different customers. !--- The eBGP sessions are configured within the VRF address family
! end
|
| PE-2 |
hostname PE-2
!
ip cef !
vrf definition Client_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
address-family ipv4
exit-address-family
! vrf definition Client_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
address-family ipv4
exit-address-family
!
ip cef
!
interface Loopback0
ip address 10.10.10.6 255.255.255.255 ip router isis !
interface GigabitEthernet0/0
description link to P-2
ip address 10.1.1.22 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/1
vrf forwarding Client_B
ip address 10.0.6.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/2
vrf forwarding Client_A
ip address 10.1.6.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
interface GigabitEthernet0/3
vrf forwarding Client_A
ip address 10.0.6.2 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router isis
net 49.0001.0000.0000.0006.00
is-type level-2-only
metric-style wide
passive-interface Loopback0
!
router bgp 65000
bgp log-neighbor-changes
neighbor 10.10.10.2 remote-as 65000
neighbor 10.10.10.2 update-source Loopback0
!
address-family vpnv4
neighbor 10.10.10.2 activate
neighbor 10.10.10.2 send-community both
exit-address-family
!
address-family ipv4 vrf Client_A
neighbor 10.0.6.1 remote-as 65004
neighbor 10.0.6.1 activate
neighbor 10.1.6.1 remote-as 65004
neighbor 10.1.6.1 activate
exit-address-family
!
address-family ipv4 vrf Client_B
neighbor 10.0.6.1 remote-as 65003
neighbor 10.0.6.1 activate
exit-address-family
!
!
end
|
| P-2 |
hostname P-2
!
ip cef
!
interface Loopback0
ip address 10.10.10.3 255.255.255.255
ip router isis
!
interface GigabitEthernet0/0
description link to PE-2
ip address 10.1.1.21 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/1
description link to P-1
ip address 10.1.1.6 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/2
description link to RR
ip address 10.1.1.9 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
router isis
net 49.0001.0000.0000.0003.00
is-type level-2-only
metric-style wide
passive-interface Loopback0
!
end
|
| RR |
hostname RR
!
ip cef
!
interface Loopback0
ip address 10.10.10.2 255.255.255.255
ip router isis
!
interface GigabitEthernet0/0
description link to P-1
ip address 10.1.1.2 255.255.255.252ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/1
description link to P-2
ip address 10.1.1.10 255.255.255.252ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/3
no ip address
shutdown
duplex auto
speed auto
media-type rj45
!
router isis
net 49.0001.0000.0000.0002.00
is-type level-2-only
metric-style wide
passive-interface Loopback0
!
router bgp 65000
bgp log-neighbor-changes
neighbor 10.10.10.4 remote-as 65000
neighbor 10.10.10.4 update-source Loopback0
neighbor 10.10.10.6 remote-as 65000
neighbor 10.10.10.6 update-source Loopback0
!
address-family vpnv4
neighbor 10.10.10.4 activate
neighbor 10.10.10.4 send-community both
neighbor 10.10.10.4 route-reflector-client
neighbor 10.10.10.6 activate
neighbor 10.10.10.6 send-community both
neighbor 10.10.10.6 route-reflector-client
exit-address-family
!
!
end
|
| P-1 |
hostname P-1
!
ip cef
!
interface Loopback0
ip address 10.10.10.1 255.255.255.255
ip router isis
!
interface GigabitEthernet0/0
description link to PE-1
ip address 10.1.1.13 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/1
description link to RR
ip address 10.1.1.5 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
interface GigabitEthernet0/2
description link to P-2
ip address 10.1.1.1 255.255.255.252
ip router isis
duplex auto
speed auto
media-type rj45
mpls ip
!
router isis
net 49.0001.0000.0000.0001.00
is-type level-2-only
metric-style wide
passive-interface Loopback0
!
end
|
| CE-A1 |
CE-A3 |
hostname CE-A1
!
ip cef
!
interface GigabitEthernet0/0
ip address 10.0.4.1 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router bgp 65002
bgp log-neighbor-changes
redistribute connected
neighbor 10.0.4.2 remote-as 65000
!
end
|
hostname CE-A3
!
ip cef
!
interface GigabitEthernet0/0
ip address 10.0.6.1 255.255.255.0
duplex auto
speed auto
media-type rj45
!
router bgp 65004
bgp log-neighbor-changes
redistribute connected
neighbor 10.0.6.2 remote-as 65000
!
end
|
确认
此部分提供可用于确认配置是否正常运行的信息:
PE 到 CE 验证命令
- show ip vrf — 验证是否存在正确的 VRF。
- show ip vrf interfaces — 验证已激活的接口。
- show ip route vrf <VRF name> - 验证 PE 路由器上的路由信息。
- traceroute vrf <VRF name> <IP address> - 验证 PE 路由器上的路由信息。
- show ip cef vrf <VRF name> <IP address> detail - 验证 PE 路由器上的路由信息。
MPLS LDP 验证命令
- show mpls interfaces
- show mpls forwarding-table
- show mpls ldp bindings
- show mpls ldp neighbor
PE 到 PE/RR 验证命令
- show bgp vpnv4 unicast all summary
- show bgp vpnv4 unicast all neighbor <neighbor IP address> advertised-routes - 验证发送的 VPNv4 前缀
- show bgp vpnv4 unicast all neighbor <neighbor IP address> routes - 验证收到的 VPNv4 前缀
以下是 show ip vrf 命令的命令输出示例。
PE-1#show ip vrf
Name Default RD Interfaces
Client_A 100:110 Gi0/1
Client_B 100:120 Gi0/2
以下是 show ip vrf interfaces 命令的命令输出示例。
PE-2#show ip vrf interfaces
Interface IP-Address VRF Protocol
Gi0/2 10.1.6.2 Client_A up
Gi0/3 10.0.6.2 Client_A up
Gi0/1 10.0.6.2 Client_B up
在下面的示例中,show ip route vrf 命令在两个输出中显示相同的前缀 10.0.6.0/24。这是因为远程 PE 为两个思科客户端 CE_B2 和 CE_A3 使用相同的网络,这在典型的 MPLS VPN 解决方案中是允许的。
PE-1#show ip route vrf Client_A
Routing Table: Client_A
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.0.4.0/24 is directly connected, GigabitEthernet0/1
L 10.0.4.2/32 is directly connected, GigabitEthernet0/1
B 10.0.6.0/24 [200/0] via 10.10.10.6, 11:11:11
B 10.1.6.0/24 [200/0] via 10.10.10.6, 11:24:16
PE-1#
PE-1#show ip route vrf Client_B
Routing Table: Client_B
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C 10.0.4.0/24 is directly connected, GigabitEthernet0/2
L 10.0.4.2/32 is directly connected, GigabitEthernet0/2
B 10.0.6.0/24 [200/0] via 10.10.10.6, 11:26:05
在两个站点(在本例中为 Client_A 的两个站点 [CE-A1 到 CE-A3])之间运行 traceroute 时,可以看到 MPLS 网络使用的标签堆栈(如果通过 mpls ip propagate-ttl 配置为这样做)。
CE-A1#show ip route 10.0.6.1
Routing entry for 10.0.6.0/24
Known via "bgp 65002", distance 20, metric 0
Tag 65000, type external
Last update from 10.0.4.2 11:16:14 ago
Routing Descriptor Blocks:
* 10.0.4.2, from 10.0.4.2, 11:16:14 ago
Route metric is 0, traffic share count is 1
AS Hops 2
Route tag 65000
MPLS label: none
CE-A1#
CE-A1#ping 10.0.6.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.6.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 7/8/9 ms
CE-A1#
CE-A1#traceroute 10.0.6.1 probe 1 numeric
Type escape sequence to abort.
Tracing the route to 10.0.6.1
VRF info: (vrf in name/id, vrf out name/id)
1 10.0.4.2 2 msec
2 10.1.1.13 [MPLS: Labels 20/26 Exp 0] 8 msec
3 10.1.1.6 [MPLS: Labels 21/26 Exp 0] 17 msec
4 10.0.6.2 [AS 65004] 11 msec
5 10.0.6.1 [AS 65004] 8 msec
注意:Exp 0 是用于服务质量(QoS)的实验字段。
下面的输出显示在 RR 与运营商核心网络中的某些 P 路由器之间建立的 IS-IS 和 LDP 邻接关系:
RR#show isis neighbors
Tag null:
System Id Type Interface IP Address State Holdtime Circuit Id
P-1 L2 Gi0/0 10.1.1.1 UP 25 RR.01
P-2 L2 Gi0/1 10.1.1.9 UP 23 RR.02
RR#
RR#show mpls ldp neighbor
Peer LDP Ident: 10.10.10.1:0; Local LDP Ident 10.10.10.2:0
TCP connection: 10.10.10.1.646 - 10.10.10.2.46298
State: Oper; Msgs sent/rcvd: 924/921; Downstream
Up time: 13:16:03
LDP discovery sources:
GigabitEthernet0/0, Src IP addr: 10.1.1.1
Addresses bound to peer LDP Ident:
10.1.1.13 10.1.1.5 10.1.1.1 10.10.10.1
Peer LDP Ident: 10.10.10.3:0; Local LDP Ident 10.10.10.2:0
TCP connection: 10.10.10.3.14116 - 10.10.10.2.646
State: Oper; Msgs sent/rcvd: 920/916; Downstream
Up time: 13:13:09
LDP discovery sources:
GigabitEthernet0/1, Src IP addr: 10.1.1.9
Addresses bound to peer LDP Ident:
10.1.1.6 10.1.1.9 10.10.10.3 10.1.1.21
相关信息