MPLS ×××
1、基本概念
(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。redis
2、MPLS ×××配置基本步驟
(1)在MPLS域使用IGP路由協議,使公網可以互通;
(2)CE設備正常配置,PE設備上開啓MPLS,修改MTU,創建VRF,定義RD和RT值,同時關聯與CE設備相鏈接的端口;
(3)在PE設備的家族模式下,創建MP-BGP鄰居關係,同時開啓社團屬性;
(4)在PE設備上使用雙向重發布或靜態,使CE設備可以將私網路由傳遞給PE設備;
(5)MPLS ×××創建。網絡
3、MPLS ×××案例ide
要求:
一、CE1與CE二、CE3與CE4能夠互訪
二、CE1與CE四、CE3與CE2之間不可以互訪
三、MPLS域使用EIGRP協議
四、CE1與PE1之間、CE2與PE2之間使用RIP協議
五、CE3與PE1之間、CE4與PE2之間使用OSPF協議oop
一、進行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 ui
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 3d
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 router
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 blog
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 ip
二、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
三、在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
四、在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
五、在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
六、部分路由表和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
七、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
八、在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與CE四、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)
九、部分路由表和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
4、注意一、本案例中,CE與PE之間都是使用的動態路由協議,固然也可使用靜態。可是,當路由條目較多或須要添加路由條目時,使用動態路由協議比較方便。二、要注意PE端的配置,PE端有VRF。三、當CE與PE之間使用EIGRP協議時,要注意AS號的配置。