思科路由器使用MPLS解決BGP路由黑洞

 

一、拓撲說明:

1、R1-R4使用OSPF建立IGP,然後使用MPLS網絡轉發數據;

2、R1和R4建立bgp連接;

3、R1和R5,R4和R6都使用RIP協議;

4、使R5的5.5.5.5地址能ping通R6的6.6.6.6地址

 

R1(config)# interface loopback 0

R1(config-if)# ip address 1.1.1.1 255.255.255.255

R1(config-if)# ip ospf 1 area 0

R1(config)# mpls label protocol ldp

R1(config)# mpls ldp router-id Loopback0   

R1(config)# no mpls ip propagate-ttl  

R1(config)# interface FastEthernet0/0

R1(config-if)# ip address 10.1.1.1 255.255.255.0

R1(config-if)# ip ospf 1 area 0

R1(config-if)# mpls ip

R1(config-if)# no shutdown

R1(config)# interface FastEthernet0/1

R1(config-if)# ip address 15.1.1.1 255.255.255.0

R1(config-if)# no shutdown

R1(config)# router bgp 14

R1(config-router)# no synchronization

R1(config-router)# no auto-summary

R1(config-router)# network 5.5.5.5 mask 255.255.255.255

R1(config-router)# neighbor 4.4.4.4 remote-as 14

R1(config-router)# neighbor 4.4.4.4 update-source Loopback0

R1(config-router)# neighbor 4.4.4.4 next-hop-self

R1(config)# router rip

R1(config-router)# version 2

R1(config-router)# no auto-summary

R1(config-router)# network 15.0.0.0

R1(config-router)# default-information originate    

 

R2(config)# interface loopback 0

R2(config-if)# ip address 2.2.2.2 255.255.255.255

R2(config-if)# ip ospf 1 area 0

R2(config)# mpls label protocol ldp 

R2(config)# mpls ldp router-id Loopback0  

R2(config)# no mpls ip propagate-ttl  

R2(config)# router ospf 1

R2(config-router)# mpls ldp autoconfig  

R2(config)# interface fastEthernet 0/1

R2(config-if)# ip address 12.1.1.2 255.255.255.0

R2(config-if)# ip ospf 1 area 0

R2(config-if)# no shutdown

R2(config)# interface fastEthernet 0/0

R2(config-if)# ip address 10.1.1.2 255.255.255.0

R2(config-if)# ip ospf 1 area 0

R2(config-if)# no shutdown

 

R3(config)# interface loopback 0

R3(config-if)# ip add 3.3.3.3 255.255.255.255

R3(config-if)# ip ospf 1 area 0

R3(config)# mpls label protocol ldp 

R3(config)# mpls ldp router-id Loopback0  

R3(config)# no mpls ip propagate-ttl  

R3(config)# router ospf 1

R3(config-router)# mpls ldp autoconfig

R3(config)# interface FastEthernet0/1

R3(config-if)# ip address 12.1.1.3 255.255.255.0

R3(config-if)# ip ospf 1 area 0

R3(config-if)# no shutdown

R3(config-if)# interface FastEthernet0/0

R3(config-if)# ip address 13.1.1.3 255.255.255.0

R3(config-if)# ip ospf 1 area 0

R3(config-if)# no shutdown

 

R4(config)# interface loopback 0

R4(config-if)# ip address 4.4.4.4 255.255.255.255

R4(config-if)# ip ospf 1 area 0

R4(config)# mpls label protocol ldp 

R4(config)# mpls ldp router-id Loopback0  

R4(config)# no mpls ip propagate-ttl  

R4(config-if)# interface FastEthernet0/0

R4(config-if)# ip add 13.1.1.4 255.255.255.0

R4(config-if)# ip ospf 1 area 0

R4(config-if)# mpls ip

R4(config-if)# no shutdown

R4(config-if)# interface FastEthernet0/1

R4(config-if)# ip address 16.1.1.4 255.255.255.0

R4(config-if)# no shutdown

R4(config)# router rip   

R4(config-router)# network 16.0.0.0

R4(config-router)# default-information originate

R4(config)# router bgp 14

R4(config-router)# no synchronization

R4(config-router)# no auto-summary

R4(config-router)# network 6.6.6.6 mask 255.255.255.255

R4(config-router)# neighbor 1.1.1.1 remote-as 14

R4(config-router)# neighbor 1.1.1.1 update-source Loopback0

R4(config-router)# neighbor 1.1.1.1 next-hop-self

 

R5(config)# interface loopback 0

R5(config-if)# ip address 5.5.5.5 255.255.255.255

R5(config)# interface FastEthernet0/1

R5(config-if)# ip address 15.1.1.5 255.255.255.0

R5(config-if)# no shutdown

R5(config)# router rip

R5(config-router)# network 0.0.0.0               

 

R6(config)# interface loopback 0

R6(config-if)# ip address 6.6.6.6 255.255.255.255

R6(config-if)# interface FastEthernet0/1

R6(config-if)# ip add 16.1.1.6 255.255.255.0

R6(config-if)# no shutdown

R6(config)# router rip

R6(config-router)# network 0.0.0.0

二、拓展:

R5# ping 6.6.6.6 source 5.5.5.5     //在R5上測試

R1# show ip cef 6.6.6.6  //查看cef具體的路由條目,可以看到一個標籤值,此標籤爲 4.4.4.4的標籤,所以當去往6.6.6.6的時候用標籤18來轉發數據。

 

R1# show mpls forwarding-table   //查看標籤轉發表

R1# show mpls ldp discovery    //第一階段,查看有沒有發現鄰居

R1# show mpls ldp neighbor   //第二階段,查看LDP鄰居信息

 

R1(config)# mpls label protocol ldp  //使用ldp協議分發標籤可以不配,默認爲ldp

R1(config)# mpls ldp router-id Loopback0    //使用環回口配置ldp的router-id

R1(config)# no mpls ip propagate-ttl   //在PE設備關閉該功能,tracert的時候隱藏mpls內部地址(可選配置)

R1(config-if)# mpls ip    //在接口下啓用mpls

R2(config-router)# mpls ldp autoconfig  //在參與ospf運算的接口上自動啓用mpls

R1(config-router)# default-information originate   //下發默認路由

 

三、MPLS轉發原理:

1、R5發送數據包目的地址爲6.6.6.6,查詢CEF表有默認路由下一跳爲 15.1.1.1(R1);

2、R1收到數據包後查詢CEF表(show ip cef 6.6.6.6)去往6.6.6.6需要壓入標籤18;

3、R1繼續查詢標籤轉發表(show mpls forwarding-table)本地標籤(Local)爲18,出標籤(Outgoing)爲18,將轉發到下一跳地址10.1.1.2(R2);mpls收到數據包查詢本地標籤,通過本地標籤對應的出標籤轉發(轉發前會替換出標籤的標籤值發出去)

4、R2收到帶有MPLS標籤18的數據包,查詢標籤轉發表替換出(Outgoing)標籤轉發出去;

5、到達R3查詢標籤轉發表18出標籤需要做pop動作,將MPLS頂層標籤彈出,還原成IP數據包發出;

6、R4收到的IP數據包查詢CEF表中6.6.6.6的下一跳地址爲16.1.1.6轉發出去給,自然到達了R6的6.6.6.6地址。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章