1、实验拓扑 2、各端口基本互联配置,各路由器开启环回口 R1-R4:AS100 ;R1、R5:AS 200;R4、R6:AS 300 3、实验目的:要求CE1与CE2环回口互通 4、a、原理 按上图配置好BGP,R5使用环回口pingR6换回口是不通的,原因是在R2,R3上出现的路由黑洞(没有1.1.1.1和6.6.6.6的路由),所以R1与R6互ping都不通。 R5#ping 6.6.6.6 source 5.5.5.5 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds: Packet sent with a source address of 5.5.5.5 ..... Success rate is 0 percent (0/5) 解决BGP路由黑洞有很多种,我们其中最简单的一种通过MPLS来解决,只需要在IBGP端口运行MPLS IP。 配置好MPLS后再ping,可以互通 Router#ping 6.6.6.6 source 5.5.5.5 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds: Packet sent with a source address of 5.5.5.5 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/3 ms b、原因 MPLS将不为通过BGP学习到的路由条目分发标签号; 但是在访问BGP学习的目标时,封装该目标BGP下一跳地址所在网段的标签号; 使中间未运行BGP协议的路由器,基于标签号将流量转发到BGP的下一跳处,来避免路由黑洞。 c、查看FIB表,跟踪标签情况 R1#sh ip cef detail 6.6.6.0/24, epoch 0, flags [rib only nolabel, rib defined all labels] recursive via 4.4.4.4 recursive via 4.4.4.0/24 nexthop 12.12.12.2 Ethernet0/0 label 201 到R1 查看FIB表,发现去往6.6.6.6标签号为201 d、查看LFIB表,跟踪标签情况 R1#sh mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop
Label Label or Tunnel Id Switched interface
100 Pop Label 2.2.2.0/24 0 Et0/0 12.12.12.2
101 203 3.3.3.0/24 0 Et0/0 12.12.12.2
**102 201 4.4.4.0/24 0 Et0/0 12.12.12.2 ** 103 Pop Label 23.23.23.0/24 0 Et0/0 12.12.12.2
104 202 34.34.34.0/24 0 Et0/0 12.12.12.2

在查找LFIB表 走4.4.4.4出去,欺骗了R2和R3,最后在R4弹出标签,到6.6.6.6 e、查看入出标签情况 Router#sh mpls ip binding 1.1.1.0/24 in label: imp-null
out label: 200 lsr: 2.2.2.2:0
2.2.2.0/24 in label: 100
out label: imp-null lsr: 2.2.2.2:0 inuse 3.3.3.0/24 in label: 101
out label: 203 lsr: 2.2.2.2:0 inuse 4.4.4.0/24 in label: 102
out label: 201 lsr: 2.2.2.2:0 inuse 12.12.12.0/24 in label: imp-null
out label: imp-null lsr: 2.2.2.2:0
15.15.15.0/24 in label: imp-null
23.23.23.0/24 in label: 103
out label: imp-null lsr: 2.2.2.2:0 inuse 34.34.34.0/24 in label: 104
out label: 202 lsr: 2.2.2.2:0 inuse 通过标签可以看到:label 201是mpls分配给igp路由4.4.4.0的。

5、配置:

R1: interface Loopback0 ip address 1.1.1.1 255.255.255.0 ! interface Ethernet0/0 ip address 12.12.12.1 255.255.255.0 mpls ip ! interface Ethernet0/1 ip address 15.15.15.1 255.255.255.0

router eigrp 100 network 1.1.1.0 0.0.0.255 network 12.12.12.0 0.0.0.255 ! router bgp 100 bgp router-id 1.1.1.1 bgp log-neighbor-changes network 1.1.1.0 mask 255.255.255.0 neighbor 4.4.4.4 remote-as 100 neighbor 4.4.4.4 update-source Loopback0 neighbor 4.4.4.4 next-hop-self neighbor 15.15.15.5 remote-as 200

R2: interface Loopback0 ip address 2.2.2.2 255.255.255.0 ! interface Ethernet0/0 ip address 12.12.12.2 255.255.255.0 mpls ip ! interface Ethernet0/1 ip address 23.23.23.2 255.255.255.0 mpls ip

router eigrp 100 network 2.2.2.0 0.0.0.255 network 12.12.12.0 0.0.0.255 network 23.23.23.0 0.0.0.255

R3:

! interface Loopback0 ip address 3.3.3.3 255.255.255.0 ! interface Ethernet0/0 ip address 23.23.23.3 255.255.255.0 mpls ip ! interface Ethernet0/1 ip address 34.34.34.3 255.255.255.0 mpls ip

router eigrp 100 network 3.3.3.0 0.0.0.255 network 23.23.23.0 0.0.0.255 network 34.34.34.0 0.0.0.255

R4: ! interface Loopback0 ip address 4.4.4.4 255.255.255.0 ! interface Ethernet0/0 ip address 34.34.34.4 255.255.255.0 mpls ip ! interface Ethernet0/1 ip address 46.46.46.4 255.255.255.0

! router eigrp 100 network 4.4.4.0 0.0.0.255 network 34.34.34.0 0.0.0.255 ! router bgp 100 bgp router-id 4.4.4.4 bgp log-neighbor-changes network 4.4.4.0 mask 255.255.255.0 neighbor 1.1.1.1 remote-as 100 neighbor 1.1.1.1 update-source Loopback0 neighbor 1.1.1.1 next-hop-self neighbor 46.46.46.6 remote-as 300

R5: ! interface Loopback0 ip address 5.5.5.5 255.255.255.0 ! interface Ethernet0/0 ip address 15.15.15.5 255.255.255.0

! router bgp 200 bgp router-id 5.5.5.5 bgp log-neighbor-changes network 5.5.5.0 mask 255.255.255.0 neighbor 15.15.15.1 remote-as 100

! R6: interface Loopback0 ip address 6.6.6.6 255.255.255.0 ! interface Ethernet0/0 ip address 46.46.46.6 255.255.255.0 ! router bgp 300 bgp router-id 6.6.6.6 bgp log-neighbor-changes network 6.6.6.0 mask 255.255.255.0 neighbor 46.46.46.4 remote-as 100

最后我们可以总结出:在mpls网络中,mpls会给igp路由分配label,cef会给采用mpls分配好的label并且给下一跳是该igp的bgp路由分配该igp的label,数据在转发的时候是按照cef表进行的,这样那些没有在mpls中分配标签的bgp路由也可以按照标签进行转发。

6、相关配置命令详解

1、启用CEF

2、指定使用的标签分发协议 (可选)

3、MPLS LDP router-id lo0 fo强制更改 (可选)

4、MPLS label range 200 299 (可选)

5、运行LDP

6、修改MTU值 (可选)

查询命令:

show mpls interfaces //查看启用MPLS的接口

show mpls ldp neighbor //查看LDP的邻居表

show mpls ldp bindings //查看LIB表

show mpls forwarding-table //查看标签转发表LFIB

show mpls ip binding //可以直接看到一条路由的入标签和出标签

show ip cef //查看FIB表

show mpls ldp discovery detail //可看到transport-address

基本命令:

rouer(config)#ip cef

rouer(config)#int s0/0

rouer(config-if)#mpls ip //在接口下启用MPLS

可选命令:

rouer(config)#mpls label protocol ldp //指定使用LDP

rouer(config)#mpls ldp router-id lo0 //指定lo0为router-id

rouer(config)#mpls label range 200 299 //指定路由器分配标签的范围,需要重新建立TCP连接

rouer(config-if)#mpls ldp discovery transport-address interface //指定自已的transport-address