實驗拓撲圖redis
實驗描述:如上圖所示,現PE-R一、P-R二、PE-R3爲MPLS ×××網絡,兩CE客戶須要經過MPLS ×××骨幹網絡進行通訊,而且CE-R4與CE-R6之間有一條鏈路做爲備份鏈路,正常狀況要,R4至R6的流量經過MPLS ×××網絡走,當MPLS ×××網絡存在故障時,經過R4與R6之間的互聯鏈路走,下面配置OSPF Sham-Link實現上述要求。網絡
一、首先配置MP-BGP,MPLS,VRF,PE與CE的OSPF路由協議ide
PE-R1的配置:oop
R1#show runn測試
ip vrf Maoui
rd 100:10spa
route-target export 100:10router
route-target import 100:11blog
!接口
ip cef
mpls label range 100 199
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
ip vrf forwarding Mao
ip address 14.1.1.1 255.255.255.252
interface FastEthernet1/0
ip address 12.1.1.1 255.255.255.252
mpls ip
router ospf 2 vrf Mao
redistribute bgp 100 subnets
network 14.1.1.0 0.0.0.3 area 1
!
router ospf 1
router-id 1.1.1.1
network 1.1.1.1 0.0.0.0 area 0
network 12.1.1.0 0.0.0.3 area 0
!
router bgp 100
bgp log-neighbor-changes
no bgp default ipv4-unicast
neighbor 3.3.3.3 remote-as 100
neighbor 3.3.3.3 update-source Loopback0
!
address-family ***v4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 send-community extended
exit-address-family
!
address-family ipv4 vrf Mao
redistribute ospf 2 match internal external 1 external 2
exit-address-family
P-R2配置:
ip cef
mpls label range 200 299
interface Loopback0
ip address 2.2.2.2 255.255.255.255
interface FastEthernet0/0
ip address 12.1.1.2 255.255.255.252
mpls ip
interface FastEthernet0/1
ip address 23.1.1.1 255.255.255.252
mpls ip
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 12.1.1.0 0.0.0.3 area 0
network 23.1.1.0 0.0.0.3 area 0
PE-R3配置:
R3#show runn
ip vrf Mao
rd 100:10
route-target export 100:11
route-target import 100:10
ip cef
mpls label range 300 399
!
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 23.1.1.2 255.255.255.252
mpls ip
!
interface FastEthernet0/1
ip vrf forwarding Mao
ip address 36.1.1.1 255.255.255.252
!
router ospf 2 vrf Mao
redistribute bgp 100 subnets
network 36.1.1.0 0.0.0.3 area 1
!
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 23.1.1.0 0.0.0.3 area 0
!
router bgp 100
bgp log-neighbor-changes
no bgp default ipv4-unicast
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback0
!
address-family ***v4
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 send-community extended
exit-address-family
!
address-family ipv4 vrf Mao
redistribute ospf 2 match internal external 1 external 2
exit-address-family
CE-R4的配置:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 14.1.1.2 255.255.255.252
interface FastEthernet0/1
ip address 46.1.1.1 255.255.255.252
!
router ospf 10
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 1
network 14.1.1.0 0.0.0.3 area 1
network 46.1.1.0 0.0.0.3 area 1
CE-R6的配置:
interface Loopback0
ip address 6.6.6.6 255.255.255.255
!
interface FastEthernet0/0
ip address 36.1.1.2 255.255.255.252
interface FastEthernet0/1
ip address 46.1.1.2 255.255.255.252
router ospf 2
router-id 6.6.6.6
network 6.6.6.6 0.0.0.0 area 1
network 36.1.1.0 0.0.0.3 area 1
network 46.1.1.0 0.0.0.3 area 1
二、CE端路由狀況分析
查看CE端路由狀況
R4#show ip route
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
6.0.0.0/32 is subnetted, 1 subnets
O 6.6.6.6 [110/2] via 46.1.1.2, 00:10:24, FastEthernet0/1
14.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 14.1.1.0/30 is directly connected, FastEthernet0/0
L 14.1.1.2/32 is directly connected, FastEthernet0/0
36.0.0.0/30 is subnetted, 1 subnets
O 36.1.1.0 [110/2] via 46.1.1.2, 00:10:24, FastEthernet0/1
46.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 46.1.1.0/30 is directly connected, FastEthernet0/1
L 46.1.1.1/32 is directly connected, FastEthernet0/1
從CE-R4看到6.6.6.6路由爲區域內路由,是因爲CE-R4與CE-R6之間互聯的線路運行OSPF,而且在區域1中,而從MPLS ×××骨幹網絡中傳過來的6.6.6.6路由爲區域間路由;而OSPF的選路原則是區域內路由優於區域間路由;
在PE-R1上查看×××V4路由,也能夠看到6.6.6.6的路由,下一跳指向的是CE-R4,以下:
R1#show ip bgp ***v4 all
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 100:10 (default for vrf Mao)
* i 4.4.4.4/32 3.3.3.3 3 100 0 ?
*> 14.1.1.2 2 32768 ?
*> 6.6.6.6/32 14.1.1.2 3 32768 ?
* i 3.3.3.3 2 100 0 ?
* i 14.1.1.0/30 3.3.3.3 3 100 0 ?
*> 0.0.0.0 0 32768 ?
*> 36.1.1.0/30 14.1.1.2 3 32768 ?
* i 3.3.3.3 0 100 0 ?
*> 46.1.1.0/30 14.1.1.2 2 32768 ?
* i 3.3.3.3 2 100 0 ?
R1#show ip route vrf Mao
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/2] via 14.1.1.2, 00:40:39, FastEthernet0/0
6.0.0.0/32 is subnetted, 1 subnets
O 6.6.6.6 [110/3] via 14.1.1.2, 00:23:00, FastEthernet0/0
14.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 14.1.1.0/30 is directly connected, FastEthernet0/0
L 14.1.1.1/32 is directly connected, FastEthernet0/0
36.0.0.0/30 is subnetted, 1 subnets
O 36.1.1.0 [110/3] via 14.1.1.2, 00:23:00, FastEthernet0/0
46.0.0.0/30 is subnetted, 1 subnets
O 46.1.1.0 [110/2] via 14.1.1.2, 00:23:00, FastEthernet0/0
當將CE-R4與CE-R6互聯的線路shutdown後,查看R4的路由以下:
R4(config)#int fa0/1
R4(config-if)#shutdown
R4#show ip route
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
6.0.0.0/32 is subnetted, 1 subnets
O IA 6.6.6.6 [110/3] via 14.1.1.1, 00:00:52, FastEthernet0/0
14.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 14.1.1.0/30 is directly connected, FastEthernet0/0
L 14.1.1.2/32 is directly connected, FastEthernet0/0
36.0.0.0/30 is subnetted, 1 subnets
O IA 36.1.1.0 [110/2] via 14.1.1.1, 00:00:52, FastEthernet0/0
46.0.0.0/30 is subnetted, 1 subnets
O IA 46.1.1.0 [110/3] via 14.1.1.1, 00:00:52, FastEthernet0/0
如今看到的路由是區域間路由,是PE-R1傳過來的,爲實現網絡的可靠性,正常狀況下,R4與R6之間的鏈路是備份線路,平時數據經過MPLS ×××傳遞,爲實現上述R4路由輸出狀況,如今在PE路由器之間配置Sham-Link實現兩CE端平常數據經過MPLS ×××網絡傳遞,當MPLS ×××網絡出現故障時,數據流量切換至R4與R6的互聯線路,以便不影響兩CE端的互訪。
三、Sham-Link配置
R1(config)#int loo 11 //用於創建OSPF Sham-Link
R1(config-if)#ip vrf forwarding Mao
R1(config-if)#ip add 11.1.1.1 255.255.255.255
R1(config)#router bgp 100
R1(config-router)#address-family ipv4 vrf Mao
R1(config-router-af)#network 11.1.1.1 mask 255.255.255.255 //將其發佈至MP-BGP中
R1(config)#router ospf 2 vrf Mao
R1(config-router)#area 1 sham-link 11.1.1.1 33.1.1.1 cost 5 //建立sham-link
R3(config)#int loo 33
R3(config-if)#ip vrf forwarding Mao
R3(config-if)#ip add 33.1.1.1 255.255.255.255
R3(config)#router bgp 100
R3(config-router)#address-family ipv4 vrf Mao
R3(config-router-af)#network 33.1.1.1 mask 255.255.255.255
R3(config)#router ospf 2 vrf Mao
R3(config-router)#area 1 sham-link 33.1.1.1 11.1.1.1 cost 5
查看其鄰居是否創建成功,可用show ip ospf neighbor或者show ip ospf sham-link
R3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:36 23.1.1.1 FastEthernet0/0
14.1.1.1 0 FULL/ - 00:00:30 11.1.1.1 OSPF_SL0
6.6.6.6 1 FULL/DR 00:00:36 36.1.1.2 FastEthernet0/1
R3#show ip ospf sham-links
Sham Link OSPF_SL0 to address 11.1.1.1 is up
Area 1 source address 33.1.1.1
Run as demand circuit
DoNotAge LSA allowed. Cost of using 5 State POINT_TO_POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40,
Hello due in 00:00:04
Adjacency State FULL (Hello suppressed)
Index 2/2, retransmission queue length 0, number of retransmission 0
First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
Last retransmission scan length is 0, maximum is 0
Last retransmission scan time is 0 msec, maximum is 0 msec
四、Sham-link配置分析及結果分析
上面sham-link的配置設置了cost值爲5,那麼PE-PE之間這條sham-link的開銷值就爲5,此時查看R4上的路由,6.6.6.6的路由下一跳仍是直接指向R6,並無走MPLS ×××網絡。
R4#show ip route
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
6.0.0.0/32 is subnetted, 1 subnets
O 6.6.6.6 [110/2] via 46.1.1.2, 00:13:09, FastEthernet0/1
11.0.0.0/32 is subnetted, 1 subnets
O E2 11.1.1.1 [110/1] via 14.1.1.1, 00:10:07, FastEthernet0/0
14.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 14.1.1.0/30 is directly connected, FastEthernet0/0
L 14.1.1.2/32 is directly connected, FastEthernet0/0
33.0.0.0/32 is subnetted, 1 subnets
O E2 33.1.1.1 [110/1] via 14.1.1.1, 00:09:31, FastEthernet0/0
36.0.0.0/30 is subnetted, 1 subnets
O 36.1.1.0 [110/2] via 46.1.1.2, 00:13:09, FastEthernet0/1
46.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 46.1.1.0/30 is directly connected, FastEthernet0/1
L 46.1.1.1/32 is directly connected, FastEthernet0/1
查看R1上的bgp ***v4 6.6.6.6的路由狀況
R1#show ip bgp ***v4 all 6.6.6.6
BGP routing table entry for 100:10:6.6.6.6/32, version 43
Paths: (2 available, best #1, table Mao)
Advertised to update-groups:
1
Refresh Epoch 1
Local
14.1.1.2 from 0.0.0.0 (1.1.1.1) //來至CE-R4,而且是最優
Origin incomplete, metric 3, localpref 100, weight 32768, valid, sourced, best
Extended Community: RT:100:10 OSPF DOMAIN ID:0x0005:0x000000020200
OSPF RT:0.0.0.1:2:0 OSPF ROUTER ID:14.1.1.1:0
mpls labels in/out 108/nolabel
rx pathid: 0, tx pathid: 0x0
Refresh Epoch 1
Local
3.3.3.3 (metric 3) from 3.3.3.3 (3.3.3.3) //來至PE-R3,不是最優的
Origin incomplete, metric 2, localpref 100, valid, internal //metric 爲2
Extended Community: RT:100:11 OSPF DOMAIN ID:0x0005:0x000000020200
OSPF RT:0.0.0.1:2:0 OSPF ROUTER ID:36.1.1.1:0
mpls labels in/out 108/307
rx pathid: 0, tx pathid: 0
從上述路由輸出分析可知,R6直接傳給R4(之間互聯線路)的6.6.6.6的路由,其OSPF開銷值爲2;而從MPLS ×××網絡經PE-R3傳至PE-R1的6.6.6.6路由的開銷值爲2,若是傳遞至R4,那麼開銷值爲8(5+2+1),其值大於R6直接傳給R4的開銷值,所以R6直接傳給R4的6.6.6.6的路由將會加入路由表項,所以在R4的路由表中將會看到6.6.6.6的下一跳仍是指向46.1.1.2。
要想實現兩CE端互訪經過MPLS ×××網絡,能夠修改COST值來實現,現修改R4與R6互聯接口的ospf cost值;
R4(config)#int fa0/1
R4(config-if)#ip ospf cost 10 將其cost值設置大於經過MPLS ×××的cost值
R6(config)#int fa0/1
R6(config-if)#ip ospf cost 10
如今R4上查看路由表狀況
R4#show ip route
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
6.0.0.0/32 is subnetted, 1 subnets
O 6.6.6.6 [110/8] via 14.1.1.1, 00:25:30, FastEthernet0/0 //下一跳指向PE-R1
11.0.0.0/32 is subnetted, 1 subnets
O E2 11.1.1.1 [110/1] via 14.1.1.1, 00:44:40, FastEthernet0/0
14.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 14.1.1.0/30 is directly connected, FastEthernet0/0
L 14.1.1.2/32 is directly connected, FastEthernet0/0
33.0.0.0/32 is subnetted, 1 subnets
O E2 33.1.1.1 [110/1] via 14.1.1.1, 00:44:04, FastEthernet0/0
36.0.0.0/30 is subnetted, 1 subnets
O 36.1.1.0 [110/7] via 14.1.1.1, 00:25:30, FastEthernet0/0
46.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 46.1.1.0/30 is directly connected, FastEthernet0/1
L 46.1.1.1/32 is directly connected, FastEthernet0/1
測試:
R4#traceroute 6.6.6.6
Type escape sequence to abort.
Tracing the route to 6.6.6.6
VRF info: (vrf in name/id, vrf out name/id)
1 14.1.1.1 136 msec 84 msec 92 msec
2 12.1.1.2 [MPLS: Labels 201/307 Exp 0] 140 msec 124 msec 144 msec
3 36.1.1.1 [MPLS: Label 307 Exp 0] 120 msec 112 msec 60 msec
4 36.1.1.2 156 msec 168 msec 112 msec
//307爲MP-BGP分配的內層標籤
五、總結
配置sham-link時要根據CE端備份鏈路所在區域來配置所屬區域,若是配置其它區域,該PE發佈的至CE端路由將會變成區域間路由,優先級低於區域內路由,所以須要將sham-link配置與備份鏈路所屬區域在同一區域中。若是兩CE端沒有備份鏈路,也就不須要配置sham-link鏈路了。
在調整CE端的選路時,須要根據sham-link配置的COST值及備份鏈路的接口cost值來完成。