资源描述
CCNP第二十一讲-MPLS VPN
VPN的分类:
Overlay VPN:运营商端设备对于客户端来说是透明的,不负责、不介入路由的传递,不存储私网路由,主要在客户端配置,费用低。
点到点VPN:运营商端路由器参与私网传递。主要在运营商端进行配置。Mpls vpn比覆盖性vpn更安全,费用较高。
MPLS VRF:(Virtual Routing Forwarding)一个VRF就是一个mpls vpn 的进程或者实例,一台PE,为一个公司提供MPLS VPN,就要为该公司同一个本地唯一的VRF进程。PE路由器上每一个VPN用户都有有一个VRF。区分不同的VRF,为每个VRF启用不同的名称,VRF的名称对于PE路由器只具有本地意义。
PE路由器除了维护全局 IP 路由表之外,还为每个VRF维护一张独立的IP 路由表,这张路由表称为VRF路由表。
PE创建了一个VRF进程,一定要将其和某个连接CE接口关联,用来存储该公传递过来的私网路由。
VRF的名称对于PE路由器只具有本地意义。
如何让来自不同公司的内网路由在ISP内网区分?
RD(Router Distinguishers)路由区分器64bit,只具有本地意义,X:Y, RD的功能并不是VPN标示符,因为在一些复杂的VPN环境中,可能一个VPN存在多个 RD。RD的最重要的两个功能:
1. 与32bits 的Ipv4前缀一起构成96bits 的VPNv4前缀;
2. 如果不同的VPN客户,存在相同的IP v4地址空间,那么可以通过设置不同的RD值从而保证前缀的唯一性
为不同的公司定义不同RD值
VPNv4路由:P路由器不参与VPNv4路由传递,R2如何把VPNv4路由传递到R3?使用BGPv4加。
R3收到VPNv4路由加入到那张路由表,因为R3的接受接口没有跟任何VRF接口关联。
RT:R3通过RT指导该如何把VPNv4路由加入到哪一张表。RT(Router Target)Route Targets 这玩意就是用来区分VPN customer的。是BGP community 的扩展属性,在VRF中进行配
置。它跟在VPNv4前缀后面被一起传递。一条路由可以附加多个RT值.
RT定义了两个操作:Export :导出,Import 导入
Export RTs
通过在vrf 中定义export RT 值,将使得输出的VPNv4路由携带上该RT 值一起传递 – 以BGP扩展community 的方式。注意这些VPNv4路由,是由VPN客户的 IPv4 路由导入 VRF后,加上 VRF中配置的RD值所形成的。
Import RTs
PE会从其他 MP-BGP对等体的PE那收到VPNv4的前缀,这些前缀都是携带RT值的。默认情况下,PE
是不会将这些VPNv4路由以IPv4的形式装载到VRF路由表里,除非在本地的VRF中,配置import RTs ,那么如果import RTs 与收到的 VPNv4前缀中的RT匹配的话,这些VPNv4前缀才会被以IPv4的形式装载到相应的VRF路由表里,相当于在这里 RT起到一个前缀过滤或者识别的作用,这个功能在许多场景中非常有用。 VPNv4路由可能携带不止一个RT 值,只要有一个匹配import RT 即可导入到VRF 路由表。
RT具有全局意义,RT既要导入又要导出。
无论对报文打几层标签,只会处理最外层标签。
实验目的:公司A总部的私网路由能通过ISP访问公司A分支的私网。让两个网段看起来像在一个网段内。公司B总部和分支能通过ISP互相访问。
1. 首先配置R1、R2、R3、R4、R5、R6接口IP,确保直连接口可以ping通。
R1(config)#int loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config)#int fa0/0
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config)#no shutdown
R1(config)#int fa1/0
R1(config-if)#ip address 13.1.1.1 255.255.255.0
R1(config)#no shutdown
R2(config)#int loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config)#int fa0/0
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#int loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config)#int fa0/0
R3(config-if)#ip address 13.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R4(config)#int loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config)#int s0/0
R4(config-if)#ip address 24.1.1.4 255.255.255.0
R4(config-if)#no shutdown
R5(config)#int loopback 0
R5(config-if)#ip address 5.5.5.5 255.255.255.0
R5(config)#int s0/0
R5(config-if)#ip address 35.1.1.5 255.255.255.0
R5(config-if)#no shutdown
R6(config)#int loopback 0
R6(config-if)#ip address 6.6.6.6 255.255.255.0
R6(config)#int s0/0
R6(config-if)#ip address 26.2.2.6 255.255.255.0
R6(config-if)#no shutdown
R7(config)#int loopback 0
R7(config-if)#ip address 7.7.7.7 255.255.255.0
R7(config)#int s0/0
R7(config-if)#ip address 37.1.1.7 255.255.255.0
R7(config-if)#noshutdown
2. 配置MPLS BACKBONE的IGP路由器,本实验采用rip(一般ISP使用IS-IS)
在R1、R2、R3之间运行RIP
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#network 1.0.0.0
R1(config-router)#network 12.0.0.0
R1(config-router)#network 13.0.0.0
R2(config)#router rip
R2(config-rouetr)#version 2
R2(config-router)#no auto-summary
R2(config-router)#network 2.0.0.0
R2(config-router)#network 12.0.0.0
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#network 3.0.0.0
R3(config-router)#network 13.0.0.0
3. 查看MPLS骨干网路由表,确认IGP是否正常工作
R2#show ip route rip
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 12.1.1.1, 00:00:06, FastEthernet0/0
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/2] via 12.1.1.1, 00:00:06, FastEthernet0/0
13.0.0.0/24 is subnetted, 1 subnets
R 13.1.1.0 [120/1] via 12.1.1.1, 00:00:06, FastEthernet0/0
R2#
4. 配置PE路由器(R2、R3)的MPLS
R2(config)#int fa0/0
R2(config-if)#mpls ip
R3(config)#int fa0/0
R3(config-if)#mpls ip
选择使用环回口作为LSR的router-id
R1(config)#mpls ldp router-id loopback 0 force
R2(config)#mpls ldp router-id loopback 0 force
R3(config)#mpls ldp router-id loopback 0 force
5.配置骨干路由器P(R1)的MPLS
在ISP内网路由器启用CEF
R1(config)#ip cef
R2(config)#ip cef
R3(config)#ip cef
接口开启标签交换功能
R1(config)#int fa0/0
R1(config-if)#mpls ip
R1(config)#int fa1/0
R1(config-if)#mpls ip
6.在任意一台MPLS骨干路由器查看FLIB(标签转发表),确认MPLS正常工作
R2#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 1.1.1.0/24 0 Fa0/0 12.1.1.1
17 17 3.3.3.0/24 0 Fa0/0 12.1.1.1
18 Pop tag 13.1.1.0/24 0 Fa0/0 12.1.1.1
R2#
查看FIB表
R2#show ip cef
Prefix Next Hop Interface
0.0.0.0/0 drop Null0 (default route handler entry)
0.0.0.0/32 receive
1.1.1.0/24 12.1.1.1 FastEthernet0/0
2.2.2.0/24 attached Loopback0
2.2.2.0/32 receive
2.2.2.2/32 receive
2.2.2.255/32 receive
3.3.3.0/24 12.1.1.1 FastEthernet0/0
12.1.1.0/24 attached FastEthernet0/0
12.1.1.0/32 receive
12.1.1.1/32 12.1.1.1 FastEthernet0/0
12.1.1.2/32 receive
12.1.1.255/32 receive
13.1.1.0/24 12.1.1.1 FastEthernet0/0
224.0.0.0/4 drop
224.0.0.0/24 receive
255.255.255.255/32 receive
R2#
查看mpls邻居信息
R1#show mpls ldp neighbor
Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 1.1.1.1:0
TCP connection: 2.2.2.2.39042 - 1.1.1.1.646
State: Oper; Msgs sent/rcvd: 98/98; Downstream
Up time: 01:19:47
LDP discovery sources:
FastEthernet0/0, Src IP addr: 12.1.1.2
Addresses bound to peer LDP Ident:
12.1.1.2 2.2.2.2
Peer LDP Ident: 3.3.3.3:0; Local LDP Ident 1.1.1.1:0
TCP connection: 3.3.3.3.16193 - 1.1.1.1.646
State: Oper; Msgs sent/rcvd: 99/98; Downstream
Up time: 01:19:28
LDP discovery sources:
FastEthernet1/0, Src IP addr: 13.1.1.3
Addresses bound to peer LDP Ident:
13.1.1.3 3.3.3.3
R1#
R2#show mpls ldp binding
tib entry: 1.1.1.0/24, rev 2
local binding: tag: 16
remote binding: tsr: 1.1.1.1:0, tag: imp-null
tib entry: 2.2.2.0/24, rev 4
local binding: tag: imp-null
remote binding: tsr: 1.1.1.1:0, tag: 16
tib entry: 3.3.3.0/24, rev 6
local binding: tag: 17
remote binding: tsr: 1.1.1.1:0, tag: 17
tib entry: 12.1.1.0/24, rev 8
local binding: tag: imp-null
remote binding: tsr: 1.1.1.1:0, tag: imp-null
tib entry: 13.1.1.0/24, rev 10
local binding: tag: 18
remote binding: tsr: 1.1.1.1:0, tag: imp-null
7. 配置VRF
R2(config)#ip vrf A
R2(config-vrf)#rd 10:10
R2(config-vrf)#route-target 10:10
R2(config)#int s1/0
R2(config-if)#ip vrf forwarding A //将vrf与接口关联起来
R2(config-if)#ip address 24.1.1.2 255.255.255.0
R2(config-if)#no shutdown
注意L配置vrf与接口关联,会使接口原来配置的IP地址丢失,重新配置一次就好
R3(config)#ip vrf A
R3(config-vrf)#rd 10 :10
R3(config-vrf)#route-target 10:10
R3(config)#int s1/0
R3(config-if)#ip vrf forwarding A
R3(config-if)#ip address 35.1.1.3 255.255.255.0
R3(config-if)#no shutdown
R2#Show ip vrf
R2#show ip vrf
Name Default RD Interfaces
A 10:10 Se1/0
B 20:20 Se1/1
R2#
8. 在两台PE路由器上配置BGP配置BGP协议是为了启用MP-BGP,用于在PE路由器之间交换VPN路由。由于BGP创建邻居时,不要求对等体物理直连,因此BGP使用tcp179端口进行邻居的会话
R2(config)#router bgp 1
R2(config-router)#no auto-summary
R2(config-router)#no synchronization
R2(config-router)#no bgp default ipv4-unicast
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 3.3.3.3 remote-as 1
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0
R2(config-router)#neighbor 3.3.3.3 next-hop-self
R3(config)#router bgp 1
R3(config-router)#no auto-summary
R3(config-router)#no synchronization
R3(config-router)#no bgp default ipv4-unicast
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 2.2.2.2 remote-as 1
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0
9. 激活两台PE路由器MP-BGP协议,其目的是用于交换不同VPN CE上的路由
R2(config)#router bgp1
R2(config-router)#address-family vpnv4 //要启用MP-BGP协议,必须在VPNV4的地址簇夏激活
R2(config-router-af)#neighbor 3.3.3.3 activate //用于激活MP-BGP邻居的路由交换
R2(config-router-af)#neighbor 3.3.3.3 send-community both //启用两种BGP交换
R2(config-router-af)#no auto-summary
R3(config)#router bgp 1
R3(config-router)#address-family vpnv4
R3(config-router-af)#neighbor 2.2.2.2 activate
R3(config-router-af)#neighbor 2.2.2.2 send-community both
R3(config-router-af)#no auto-summary
启用扩展共用体交换的目的是,为了MP-BGP携带RD和起源场点属性。
11. 查看R2或者R5的MP-BGP协议状态,发现现在并没有相关路由
R2#show ip bgp all summary
For address family: VPNv4 Unicast
BGP router identifier 2.2.2.2, local AS number 1
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3.3.3.3 4 1 6 6 1 0 0 00:02:44 0
R2#
配置PE和CE之间的路由选择协议和MP-BGP与RIP之间的路由重分发.
配置R2、R4之间
R2(config)#ip route vrf A 4.4.4.0 255.255.255.0 s1/0 24.1.1.4
R2(config)#router bgp 1
R2(config-router)#address-famiy ipv4 vrf A
R2(config-router-af)#redistribute static 10
R4(config)#ip route 5.5.5.0 s0/0 24.1.1.2
配置R3、R5之间
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#address-family ipv4 vrf A //启用IPv4地址家族,配置rip与vrf转发表之间的关系。
R3(config-router-af)#network 35.0.0.0
R5(config)#router rip
R5(config-router)#version 2
R5(config-router)#no auto-summary
R5(config-router)#network 5.0.0.0
R5(config-router)#network 35.0.0.0
重分发
R3(config)#router rip
R3(config-router)#address-family ipv4 vrf A
R3(config-router-af)#redistribute bgp 1 metric transparent //重分发的BGP路由度量值不变即保留bgp原始的度量值。
R3(config)#router bgp 1
R3(config-router)#address-family ipv4 vrf A
R3(config-router-af)#redistribute rip metric 10
R3查看VRF表
R3#show ip route vrf A
Routing Table: A
Codes: 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
Gateway of last resort is not set
35.0.0.0/24 is subnetted, 1 subnets
C 35.1.1.0 is directly connected, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [200/10] via 2.2.2.2, 00:25:12
查看R5的路由表
R5#sh ip route
Codes: 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
Gateway of last resort is not set
35.0.0.0/24 is subnetted, 1 subnets
C 35.1.1.0 is directly connected, Serial0/0
4.0.0.0/24 is subnetted, 1 subnets
R 4.4.4.0 [120/10] via 35.1.1.3, 00:00:05, Serial0/0
5.0.0.0/24 is subnetted, 1 subnets
C 5.5.5.0 is directly connected, Loopback0
R5#
查看R4的路由表
R4#show ip route
Codes: 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
Gateway of last resort is not set
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
5.0.0.0/24 is subnetted, 1 subnets
S 5.5.5.0 [1/0] via 24.1.1.2, Serial0/0
24.0.0.0/24 is subnetted, 1 subnets
C 24.1.1.0 is directly connected, Serial0/0
R4#
配置R2、R6和R3、R7
R2(config)#ip vrf B
R2(config-vrf)#rd 20:20
R2(config-vrf)#route-target 20:20
R2(config)#int s1/1
R2(config-if)#ip vrf forwarding B
R2(config-if)#ip address 26.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#ip vrf B
R3(config-vrf)#rd 20:20
R3(config-vrf)#route-target 20:20
R3(config)#int s1/1
R3(config-if)#ip vrf forwarding B
R3(config-if)#ip address 37.1.1.3 255.255.255.0
R3(config-if)#no shutdown
配置PE和CE之间的路由选择协议和MP-BGP与RIP之间的路由重分发.
配置R6、R2
R2(config)#router eigrp 90
R2(config-router)#no auto-summary
R2(config-router)#address-family ipv4 vrf B
R2(config-router-af)#network 26.1.1.2 0.0.0.0
R2(config-router-af)#sutononmous system 90
R6(config)#router eigrp 90
R6(config-router)#no auto-summary
R6(config-router)#network 6.6.6.6 0.0.0.0
R6(config-router)#26.1.1.6 0.0.0.0
重分发:
R2(config)#router eigrp 90
R2(config-router)#address-family ipv4 vrf B
R2(config-router)#redistribute bgp 1 metric 10000 100 255 1 1500
R2(config)#router bgp 1
R2(config-router)#address-family ipv4 vrf B
R2(config-router-af)#redistribute eigrp 90 metric 10
配置R3、R7
R3(config)#router ospf 110 vrf B
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 37.1.1.3 0.0.0.0 area 0
R7(config)#router ospf 110
R7(config-router)#router-id 7.7.7.7
R7(config-router)#network 7.7.7.7 0.0.0.0 area 0
R7(config-router)#network 37.1.1.7 0.0.0.0 area 0
重分发
R3(config)#router ospf 110 vrf B
R3(config-router)#redistribute bgp 1 subnets
R3(config)#router bgp 1
R3(config-router)#address-family ipv4 vrf B
R3(config-router)#redistribute ospf 110 vrf B match internal external 1 external 2
15.查看vrf A/B中的R4、R5、R6、R7路由表,确认MPLS VPN配置
16.ping确认路由的有效性
17。查看MP-BGP关于vrf的路由信息
R2#show ip bgp vpnv4 vrf A
BGP table version is 16, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 10:10 (default for vrf A)
*> 4.4.4.0/24 24.1.1.4 10 32768 ?
*>i5.5.5.0/24 3.3.3.3 10 100 0 ?
*>i35.1.1.0/24 3.3.3.3 0 100 0 ?
R2#
R4#ping 5.5.5.5 s
展开阅读全文