1、底层IGP(这里不再赘述)
2、在R1和R5上创建一个环回口IP地址
R1(config)#interface loopback 1
R1(config-if)#ip address 11.11.11.11 255.255.255.255
R5(config)#interface loopback 1
R5(config-if)#ip address 55.55.55.55 255.255.255.255
3、在R1、R2、R4、R5上配置静态路由
R1(config)#ip route 55.55.55.55 255.255.255.255 12.1.1.2
R2(config)#ip route 11.11.11.11 255.255.255.255 12.1.1.1
R4(config)#ip route 55.55.55.55 255.255.255.255 45.1.1.5
R5(config)#ip route 11.11.11.11 255.255.255.255 45.1.1.4
4、在R2上测试与11.11.11.11的连通性
R2#ping 11.11.11.11
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
5、在R4上测试与55.55.55.55的连通性
R4#ping 55.55.55.55
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 55.55.55.55, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
6、在R2和R4之间建立BGP邻居关系,并宣告网段
R2(config)#router bgp 100
R2(config-router)#neighbor 4.4.4.4 remote-as 100
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#neighbor 4.4.4.4 next-hop-self
R2(config-router)#network 11.11.11.11 mask 255.255.255.255
R4(config)#router bgp 100
R4(config-router)#neighbor 2.2.2.2 remote-as 100
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#neighbor 2.2.2.2 next-hop-self
R4(config-router)#network 55.55.55.55 mask 255.255.255.255
7、查看BGP邻居关系
R2#show ip bgp summary
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 3, main routing table version 3
2 network entries using 280 bytes of memory
2 path entries using 160 bytes of memory
2/2 BGP path/bestpath attribute entries using 288 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 728 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 100 12 12 3 0 0 00:07:24 1
R4#show ip bgp summary
BGP router identifier 4.4.4.4, local AS number 100
BGP table version is 3, main routing table version 3
2 network entries using 280 bytes of memory
2 path entries using 160 bytes of memory
2/2 BGP path/bestpath attribute entries using 288 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 728 total bytes of memory
BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 100 12 12 3 0 0 00:07:38 1
8、查看设备路由表
R2#show ip bgp
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 11.11.11.11/32 12.1.1.1 0 32768 i
*>i 55.55.55.55/32 4.4.4.4 0 100 0 i
R4#show ip bgp
BGP table version is 4, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i 11.11.11.11/32 2.2.2.2 0 100 0 i
*> 55.55.55.55/32 45.1.1.5 0 32768 i
9、在R1上测试与55.55.55.55的连通性
R1#ping 55.55.55.55 source 11.11.11.11
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 55.55.55.55, timeout is 2 seconds:
Packet sent with a source address of 11.11.11.11
.....
Success rate is 0 percent (0/5)
R1#traceroute 55.55.55.55 source 11.11.11.11 numeric
Type escape sequence to abort.
Tracing the route to 55.55.55.55
VRF info: (vrf in name/id, vrf out name/id)
1 12.1.1.2 0 msec 0 msec 0 msec
2 * * *
10、此时查看R3路由表
R3#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/21] via 23.1.1.2, 02:06:32, Ethernet0/1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 23.1.1.2, 02:06:32, Ethernet0/1
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/11] via 34.1.1.4, 02:05:13, Ethernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O 5.5.5.5 [110/21] via 34.1.1.4, 02:04:05, Ethernet0/0
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/20] via 23.1.1.2, 02:06:32, Ethernet0/1
23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 23.1.1.0/24 is directly connected, Ethernet0/1
L 23.1.1.3/32 is directly connected, Ethernet0/1
34.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 34.1.1.0/24 is directly connected, Ethernet0/0
L 34.1.1.3/32 is directly connected, Ethernet0/0
45.0.0.0/24 is subnetted, 1 subnets
O 45.1.1.0 [110/20] via 34.1.1.4, 02:04:15, Ethernet0/0
结论:此时在R3上形成了BGP的路由黑洞,R3设备上没有路由,导致数据的传递在此设备上被丢弃
11、在R2、R3、R4上开启LDP
R2(config)#interface ethernet 0/1
R2(config-if)#mpls ip
R3(config)#interface range ethernet 0/0-1
R3(config-if-range)#mpls ip
R4(config)#interface ethernet 0/0
R4(config-if)#mpls ip
12、此时,再在R1上与55.55.55.55进行连通性测试
R1#ping 55.55.55.55 source 11.11.11.11
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 55.55.55.55, timeout is 2 seconds:
Packet sent with a source address of 11.11.11.11
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R1#traceroute 55.55.55.55 source 11.11.11.11 numeric
Type escape sequence to abort.
Tracing the route to 55.55.55.55
VRF info: (vrf in name/id, vrf out name/id)
1 12.1.1.2 0 msec 1 msec 0 msec
2 * * *
3 34.1.1.4 1 msec 1 msec 0 msec
4 45.1.1.5 1 msec * 2 msec
注释:此时Huawei的操作到这一步是不能够联通的,因为Huawei默认先查RIB而不是FIRB;可以通过在R2和R4上执行以下命令修改
[R2]route recursive-lookup tunnel
13、查看R2、R3、R4的mpls转发表
R2#show mpls forwarding-table
Local Outgoing Prefix Bytes Label Outgoing Next Hop
Label Label or Tunnel Id Switched interface
16 No Label 1.1.1.1/32 0 Et0/0 12.1.1.1
17 Pop Label 3.3.3.3/32 0 Et0/1 23.1.1.3
18 18 4.4.4.4/32 0 Et0/1 23.1.1.3
19 19 5.5.5.5/32 0 Et0/1 23.1.1.3
20 No Label 11.11.11.11/32 0 Et0/0 12.1.1.1
21 Pop Label 34.1.1.0/24 0 Et0/1 23.1.1.3
22 21 45.1.1.0/24 0 Et0/1 23.1.1.3
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes Label Outgoing Next Hop
Label Label or Tunnel Id Switched interface
16 16 1.1.1.1/32 0 Et0/1 23.1.1.2
17 Pop Label 2.2.2.2/32 3548 Et0/1 23.1.1.2
18 Pop Label 4.4.4.4/32 3567 Et0/0 34.1.1.4
19 19 5.5.5.5/32 0 Et0/0 34.1.1.4
20 Pop Label 12.1.1.0/24 1270 Et0/1 23.1.1.2
21 Pop Label 45.1.1.0/24 1074 Et0/0 34.1.1.4
R4#show mpls forwarding-table
Local Outgoing Prefix Bytes Label Outgoing Next Hop
Label Label or Tunnel Id Switched interface
16 16 1.1.1.1/32 0 Et0/0 34.1.1.3
17 17 2.2.2.2/32 0 Et0/0 34.1.1.3
18 Pop Label 3.3.3.3/32 0 Et0/0 34.1.1.3
19 No Label 5.5.5.5/32 0 Et0/1 45.1.1.5
20 20 12.1.1.0/24 0 Et0/0 34.1.1.3
21 Pop Label 23.1.1.0/24 0 Et0/0 34.1.1.3
22 No Label 55.55.55.55/32 0 Et0/1 45.1.1.5
结论:
1、R1将报文转发给R2,R2收到后,发现目的地访问的是55.55.55.55,根据FEC(转发等价类)下一跳是4.4.4.4
2、4.4.4.4在R2上是由label的,所以R2将报文压入标签传给R3
3、R3收到带有标签的则执行标签交换,此时应该是倒数第二条弹出标签后转发给R4
4、R4收到报文后,目的地是55.55.55.55.递归查询,IP转发给R5