MPLS ×××案例

MPLS ×××
一、基本概念
(1)VRF(Virtual Routing and Forwarding) 
每个VRF可以理解为一台虚拟逻辑路由器,每台路由器可以创建多个VRF,默认情况下,VRF之间、VRF与路由器之间是隔离的,一台PE路由器分配多个VRF来连接不同的客户设备,实现同一PE下的不同客户网络信息的隔离需求。 
VRF内的路由被称为×××V4路由,×××V4路由=IPV4路由+RD值+RT值,必须使用MP-BGP路由协议来传递。
(2)RD(route distinguisher)路由标识 
RD值只是一个参数,由64位的16进制组成---X:X,是×××V4路由的前缀,用来区分不同CE端相同的路由条目。
(3)RT:Route Target 
RT值是BGP的一种扩展community属性,用来区分不同目标接收者(将PE上接收到的×××v4前缀通告给正确的CE设备),格式---X:X。
(4)MPLS ×××的数据转发原理
PE1再将数据传递给PE2时,会封装两层标签,外层标签用于穿越P路由器,内层标签用于通告PE2所查询的VRF。

二、MPLS ×××配置基本步骤
(1)在MPLS域使用IGP路由协议,使公网能够互通;
(2)CE设备正常配置,PE设备上开启MPLS,修改MTU,建立VRF,定义RD和RT值,同时关联与CE设备相连接的端口;
(3)在PE设备的家族模式下,建立MP-BGP邻居关系,同时开启社团属性;
(4)在PE设备上使用双向重发布或静态,使CE设备能够将私网路由传递给PE设备;
(5)MPLS ×××建立。

三、MPLS ×××案例

MPLS ×××案例

要求:
1、CE1与CE2、CE3与CE4可以互访
2、CE1与CE4、CE3与CE2之间不能够互访
3、MPLS域使用EIGRP协议
4、CE1与PE1之间、CE2与PE2之间使用RIP协议
5、CE3与PE1之间、CE4与PE2之间使用OSPF协议

1、进行IP配置
CE1路由器:
CE1(config-if)#int lo 0
CE1(config-if)#ip address 192.168.1.100 255.255.255.0
CE1(config)#int s0/0
CE1(config-if)#ip address 192.168.2.1 255.255.255.0
CE1(config-if)#no shutdown

PE1路由器:
PE1(config-if)#int lo 0
PE1(config-if)#ip address 2.2.2.2 255.255.255.0
PE1(config)#int s0/0
PE1(config-if)#ip address 23.1.1.2 255.255.255.0
PE1(config-if)#no shutdown

P路由器:
P(config-if)#int lo 0
P(config-if)#ip address 3.3.3.3 255.255.255.0
P(config)#int s0/1
P(config-if)#ip address 23.1.1.3 255.255.255.0
P(config-if)#no shutdown
P(config)#int s0/0
P(config-if)#ip address 34.1.1.3 255.255.255.0
P(config-if)#no shutdown

PE2路由器:
PE2(config-if)#int lo 0
PE2(config-if)#ip address 4.4.4.4 255.255.255.0
PE2(config)#int s0/0
PE2(config-if)#ip address 34.1.1.4 255.255.255.0
PE2(config-if)#no shutdown

CE2路由器:
CE2(config-if)#int lo 0
CE2(config-if)#ip address 192.168.4.100 255.255.255.0
CE2(config-if)#int lo 1
CE2(config-if)#ip address 55.1.1.100 255.255.255.0
CE2(config)#int s0/0
CE2(config-if)#ip address 192.168.3.5 255.255.255.0
CE2(config-if)#no shutdown

2、MPLS域配置EIGRP协议,使公网能够通信
PE1路由器:
PE1(config)#router eigrp 100
PE1(config-router)#no auto-summary
PE1(config-router)#network 2.0.0.0
PE1(config-router)#network 23.0.0.0

P路由器:
P(config)#router eigrp 100
P(config-router)#no auto-summary
P(config-router)#network 3.0.0.0
P(config-router)#network 23.0.0.0
P(config-router)#network 34.0.0.0

PE2路由器:
PE1(config)#router eigrp 100
PE1(config-router)#no auto-summary
PE1(config-router)#network 4.0.0.0
PE1(config-router)#network 34.0.0.0

此时,MPLS域已经可以互通,检验如下:
PE2#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 19/21/25 ms
PE1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 17/19/20 ms

3、在CE1与PE1之间、CE2与PE2之间配置RIP协议
CE1路由器:
CE1(config)#router rip
CE1(config-router)#version 2
CE1(config-router)#no auto-summary
CE1(config-router)#network 192.168.1.0
CE1(config-router)#network 192.168.2.0

PE1路由器:
先配置VRF
PE1(config)# ip cef //开启cef,一般默认开启
PE1(config)#int s0/0
PE1(config-if)#mtu 1508 //可选,建议修改
PE1(config-if)#mpls ip //在标签号经过的端口开启MPLS协议
PE1(config)#ip vrf A->B //创建名为A->B的VRF空间
PE1(config-vrf)#RD 1:1
PE1(config-vrf)#route-target 1:1
PE1(config-vrf)#exi
PE1(config)#int s0/1 //进入关联端口
PE1(config-if)#ip vrf forwarding A->B //关联VRF空间
PE1(config-if)#ip address 192.168.1.2 255.255.255.0 //重新定义地址
PE1(config-if)#no shutdown
再配置RIP协议
PE1(config-router)#router rip
PE1(config-router)#version 2
PE1(config-router)#no auto-summary
PE1(config-router)#address-family ipv4 vrf A->B //PE设备必须在VRF下宣告
PE1(config-router-af)#network 192.168.2.0
PE1(config-router-af)#exi

CE2路由器:
CE2(config)#router rip
CE2(config-router)#version 2
CE2(config-router)#no auto-summary
CE2(config-router)#network 192.168.4.0
CE2(config-router)#network 192.168.3.0
CE2(config-router)#network 55.1.1.0
CE2(config-router)#end

PE2路由器:
先配置VRF
PE2(config)#int s0/1
PE2(config-if)#mpls ip
PE2(config-if)#mtu 1508
PE2(config-if)#exi
PE2(config)#ip vrf B->A
PE2(config-vrf)#rd 1:1
PE2(config-vrf)#route-target 1:1
PE2(config-vrf)#exi
PE2(config)#int s0/0
PE2(config-if)#ip vrf forwarding B->A
PE2(config-if)#ip address 192.168.3.4 255.255.255.0
PE2(config-if)#no shutdown
在配置RIP协议
PE2(config-router)#router rip
PE2(config-router)#version 2
PE2(config-router)#no auto-summary
PE2(config-router)#address-family ipv4 vrf B->A
PE2(config-router-af)#NETwork 192.168.3.0
PE2(config-router-af)#exi

4、在PE1 与PE2之间建立MP-BGP邻居,P路由器不配置BGP协议
PE1路由器:
PE1(config)#router bgp 1
PE1(config-router)#bgp router-id 2.2.2.2
PE1(config-router)#neighbor 4.4.4.4 remote-as 1
PE1(config-router)#neighbor 4.4.4.4 update-source lo 0 //先建立IPV4邻居关系
PE1(config-router)#address-family ***v4 //进入MP-BGP家族模式
PE1(config-router-af)#neighbor 4.4.4.4 activate //建立MP-BGP邻居关系
PE1(config-router-af)#neighbor 4.4.4.4 send-community //必须开启社团属性

PE2路由器:
PE2(config)#router bgp 1
PE2(config-router)#b router-id 4.4.4.4
PE2(config-router)#neighbor 2.2.2.2 remote-as 1
PE2(config-router)#neighbor 2.2.2.2 update-source lo 0
PE2(config-router)#address-family ***v4
PE2(config-router-af)#neighbor 2.2.2.2 activate
PE2(config-router-af)#neighbor 2.2.2.2 send-community

5、在PE1和PE2上做双向重发布
PE1路由器:
将bgp重发布到rip
PE1(config)#router rip
PE1(config-router-af)#REdistribute bgp 1 metric 1

将rip重发布到bgp
PE1(config)#router bgp 1
PE1(config-router)#address-family ipv4 vrf A->B //PE端路由要在VRF下重发布到CE端
PE1(config-router-af)#REdistribute rip
PE1(config-router-af)#end

PE2路由器:
将bgp重发布到rip
PE1(config)#router rip
PE1(config-router-af)#REdistribute bgp 1 metric 1 //要带种子度量

将rip重发布到bgp
PE1(config)#router bgp 1
PE1(config-router)#address-family ipv4 vrf B->A
PE1(config-router-af)#REdistribute rip
PE1(config-router-af)#end

此时,CE1和CE2已经能过互通,检验如下:
CE1#ping 55.1.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 55.1.1.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 39/41/44 ms

CE2#ping 192.168.1.100 source 55.1.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:
Packet sent with a source address of 55.1.1.100
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 38/39/40 ms

6、部分路由表和VRF表
PE1路由器
路由表:
PE1#sho ip route
Gateway of last resort is not set
2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 2.2.2.0/24 is directly connected, Loopback0
L 2.2.2.2/32 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 23.1.1.3, 06:02:00, Serial0/0
4.0.0.0/24 is subnetted, 1 subnets
D 4.4.4.0 [90/2809856] via 23.1.1.3, 06:01:12, Serial0/0
23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 23.1.1.0/24 is directly connected, Serial0/0
L 23.1.1.2/32 is directly connected, Serial0/0
34.0.0.0/24 is subnetted, 1 subnets
D 34.1.1.0 [90/2681856] via 23.1.1.3, 06:01:21, Serial0/0

Vrf表:A->B
PE1#sho ip route vrf A->B
Routing Table: A->B
Gateway of last resort is not set
55.0.0.0/24 is subnetted, 1 subnets
B 55.1.1.0 [200/1] via 4.4.4.4, 04:58:18
R 192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:22, Serial0/1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, Serial0/1
L 192.168.2.2/32 is directly connected, Serial0/1
B 192.168.3.0/24 [200/0] via 4.4.4.4, 05:02:03
B 192.168.4.0/24 [200/1] via 4.4.4.4, 05:02:03

PE2路由器
路由表:
PE2#sho ip route
Gateway of last resort is not set
2.0.0.0/24 is subnetted, 1 subnets
D 2.2.2.0 [90/2809856] via 34.1.1.3, 06:03:43, Serial0/1
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 34.1.1.3, 06:03:43, Serial0/1
4.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 4.4.4.0/24 is directly connected, Loopback0
L 4.4.4.4/32 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
D 23.1.1.0 [90/2681856] via 34.1.1.3, 06:03:43, Serial0/1
34.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 34.1.1.0/24 is directly connected, Serial0/1
L 34.1.1.4/32 is directly connected, Serial0/1

Vrf表: B->A
PE2#sho ip route vrf B->A
Routing Table: B->A
Gateway of last resort is not set
55.0.0.0/24 is subnetted, 1 subnets
R 55.1.1.0 [120/1] via 192.168.3.5, 00:00:02, Serial0/0
B 192.168.1.0/24 [200/1] via 2.2.2.2, 05:06:06
B 192.168.2.0/24 [200/0] via 2.2.2.2, 05:06:06
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, Serial0/0
L 192.168.3.4/32 is directly connected, Serial0/0
R 192.168.4.0/24 [120/1] via 192.168.3.5, 00:00:02, Serial0/0

7、CE3与PE1之间、CE4与PE2之间使用OSPF协议
CE3路由器:
CE3(config)#int lo 0
CE3(config-if)#ip address 192.168.1.100 255.255.255.0
CE3(config-if)#int s0/0
CE3(config-if)#ip address 192.168.2.6 255.255.255.0
CE3(config-if)#no shutdown
CE3(config)#router ospf 1
CE3(config-router)#router-id 6.6.6.6
CE3(config-router)#network 192.168.1.0 0.0.0.255 a 0
CE3(config-router)#network 192.168.2.0 0.0.0.255 a 0

PE1路由器:
PE1(config)#ip vrf xian
PE1(config-vrf)#rd 2:2
PE1(config-vrf)#route-target 2:2
PE1(config-vrf)#exi
PE1(config)#int s0/2
PE1(config-if)#ip vrf forwarding xian
PE1(config-if)#ip address 192.168.2.2 255.255.255.0
PE1(config-if)#no shutdown

PE1(config)#router ospf 1 vrf xian
PE1(config-router)#router-id 2.2.2.2
PE1(config-router)#network 2.2.2.2 0.0.0.0 a 0
PE1(config-router)#network 192.168.2.0 0.0.0.255 a 0

CE4路由器:
CE4(config)#int lo 0
CE4(config-if)#ip address 192.168.4.100 255.255.255.0
CE4(config-if)#int lo 1
CE4(config-if)#ip address 77.1.1.100 255.255.255.0
CE4(config-if)#end
CE4(config-if)#int s0/0
CE4(config-if)#ip address 192.168.3.7 255.255.255.0
CE4(config-if)#no shutdown
CE4(config)#router ospf 1
CE4(config-router)#router-id 7.7.7.7
CE4(config-router)#network 192.168.4.0 0.0.0.255 a 0
CE4(config-router)#network 192.168.3.0 0.0.0.255 a 0
CE4(config-router)#network 77.1.1.0 0.0.0.255 a 0

PE2路由器:
PE2(config)#ip vrf beijing
PE2(config-vrf)#rd 2:2
PE2(config-vrf)#route-target 2:2
PE2(config-vrf)#exi
PE2(config)#int s0/2
PE2(config-if)#ip vrf forwarding beijing
PE2(config-if)#ip address 192.168.3.4 255.255.255.0
PE2(config-if)#no shutdown

PE2(config)#router ospf 1 vrf beijing
PE2(config-router)#router-id 4.4.4.4
PE2(config-router)#network 192.168.3.0 0.0.0.255 a 0

8、在PE1和PE2上做双向重发布
PE1路由器:
将bgp重发布到ospf中
PE1(config)#router ospf 1 vrf xian
PE1(config-router)#redistribute bgp 1 subnets

将ospf重发布到bgp中
PE1(config)#router bgp 1
PE1(config-router)#address-family ipv4 vrf xian
PE1(config-router-af)#redistribute ospf 1

PE2路由器:
将bgp重发布到ospf中
PE2(config)#router ospf 1 vrf beijing
PE2(config-router)#redistribute bgp 1 subnets
PE2(config-router)#exi

将ospf重发布到bgp中
PE2(config)#router bgp 1
PE2(config-router)#address-family ipv4 vrf beijing
PE2(config-router-af)#redistribute ospf 1

此时,CE3与CE4已经能够互相通信,检验如下:
CE3#ping 77.1.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 77.1.1.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 38/40/45 ms

CE4#ping 192.168.1.100 source 77.1.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:
Packet sent with a source address of 77.1.1.100
!!!!!

但是,CE1与CE4、CE3与CE2不能互通,检验如下:
CE1#ping 77.1.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 77.1.1.100, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

CE3#ping 55.1.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 55.1.1.100, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

9、部分路由表和VRF表
CE3路由器:
路由表
CE3#sho ip route
Gateway of last resort is not set
77.0.0.0/32 is subnetted, 1 subnets
O IA 77.1.1.100 [110/129] via 192.168.2.2, 00:31:50, Serial0/0
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, Loopback0
L 192.168.1.100/32 is directly connected, Loopback0
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, Serial0/0
L 192.168.2.6/32 is directly connected, Serial0/0
O IA 192.168.3.0/24 [110/65] via 192.168.2.2, 00:33:31, Serial0/0
192.168.4.0/32 is subnetted, 1 subnets
O IA 192.168.4.100 [110/129] via 192.168.2.2, 00:33:31, Serial0/0

PE1路由器:
VRF表:xian
PE1#sho ip route vrf xian
Routing Table: xian
Gateway of last resort is not set
77.0.0.0/32 is subnetted, 1 subnets
B 77.1.1.100 [200/65] via 4.4.4.4, 00:33:20
192.168.1.0/32 is subnetted, 1 subnets
O 192.168.1.100 [110/65] via 192.168.2.6, 00:47:15, Serial0/2
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, Serial0/2
L 192.168.2.2/32 is directly connected, Serial0/2
B 192.168.3.0/24 [200/0] via 4.4.4.4, 00:35:01
192.168.4.0/32 is subnetted, 1 subnets
B 192.168.4.100 [200/65] via 4.4.4.4, 00:35:01

CE4路由器:
路由表
CE4#sho ip route
Gateway of last resort is not set
77.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 77.1.1.0/24 is directly connected, Loopback1
L 77.1.1.100/32 is directly connected, Loopback1
192.168.1.0/32 is subnetted, 1 subnets
O IA 192.168.1.100 [110/129] via 192.168.3.4, 00:37:26, Serial0/0
O IA 192.168.2.0/24 [110/65] via 192.168.3.4, 00:37:26, Serial0/0
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, Serial0/0
L 192.168.3.7/32 is directly connected, Serial0/0
192.168.4.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.4.0/24 is directly connected, Loopback0
L 192.168.4.100/32 is directly connected, Loopback0

PE2路由器
VRF表:beijing
PE2#sho ip route vrf beijing
Routing Table: beijing
Gateway of last resort is not set
77.0.0.0/32 is subnetted, 1 subnets
O 77.1.1.100 [110/65] via 192.168.3.7, 00:36:28, Serial0/2
192.168.1.0/32 is subnetted, 1 subnets
B 192.168.1.100 [200/65] via 2.2.2.2, 00:42:18
B 192.168.2.0/24 [200/0] via 2.2.2.2, 00:42:18
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, Serial0/2
L 192.168.3.4/32 is directly connected, Serial0/2
192.168.4.0/32 is subnetted, 1 subnets
O 192.168.4.100 [110/65] via 192.168.3.7, 00:39:01, Serial0/2

四、注意
1、本案例中,CE与PE之间都是使用的动态路由协议,当然也可以使用静态。但是,当路由条目较多或需要添加路由条目时,使用动态路由协议比较方便。
2、要注意PE端的配置,PE端有VRF。
3、当CE与PE之间使用EIGRP协议时,要注意AS号的配置。

猜你喜欢

转载自blog.51cto.com/13596342/2155053