思科路由器使用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地址。

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