实验拓扑图:

1、配置各台路由器的IP地址,并且使用Ping命令确认各路由器的直连口的互通。
2、配置MPLS骨干区域OSPF路由。并使用show ip route命令确认OSPF路由由已经收敛。需要注意的是R2的loopback 0的接口,其子网掩码是32位的。其目的是用作于BGP的会话的更新源和LDP路由器的ID。
R2(config)#interface loopback 0
R2(config-if)#ip address 10.1.1.1 255.255.255.255
R2(config-if)#exit
R2(config)#router ospf 100
R2(config-router)#router-id 10.1.1.1
R2(config-router)#network 10.1.1.1 0.0.0.0 area 0
R2(config-router)#network 10.1.10.0 0.0.0.255 area 0
R2(config-router)#exit
在LOOPBACK 0口配置32位地址原因:这是因为OSPF在默认通告环回口时,会将其通告为32位掩码的IP地址。而其它LSR(标签交换路由器)会创建一个与PE路由器通告的OSPF相对应的标签绑定(OSPF Router-ID与LDP Router-ID),即使用32位掩码的路由。但是由于PE路由器的与标签绑定的接口LOOPBACK 0实际为24位,则会出现LSP(标签转发协议)出错,导致MPLS不能正常的工作。
也可以采用如下的配置,确保ID相同。
R2(config)#interface loopback 0
R2(config-if)#ip ospf default network point-to-point
R2(config-if)#exit
3、配置MPLS的PE路由器R2,PE全称为Provide Edge。
4、首先在R2上启用CEF。CISCO的MPLS依赖于CEF,因此必须启用CEF的快速转发机制。
R2(config)#ip cef
5、配置R2的标签转发协议。
R2(config)#mpls label protocol ldp
6、配置TDP/LDP的路由器ID。配置ID的主要目的是为了方便排错。
R2(config)#interface s1/1
R2(config-if)#mpls ip
R2(config-if)#tag-switching ip
R2(config-if)#exit
8、配置PE路由器R4的MPLS:
R4(config)#ip cef
R4(config)#mpls label protocol ldp
R4(config)#mpls ldp router-id loopback 0 force
R4(config)#
R4(config)#interface serial 1/0
R4(config-if)#mpls ip
R4(config-if)#tag-switching ip
R4(config-if)#exit
R4(config)#exit
9、配置P路由器R3。
R3(config)#ip cef
R3(config)#mpls label protocol ldp
R3(config)#mpls ldp router-id loopback 0 force
R3(config)#
R3(config)#interface serial 1/0
R3(config-if)#mpls ip
R3(config-if)#tag-switching ip
R3(config-if)#exit
R3(config)#
R3(config)#interface serial 1/1
R3(config-if)#mpls ip
R3(config-if)#tag-switching ip
R3(config-if)#exit
R3(config)#exit
R3#
10、在配置过程中,当在R2的S1/1和S1/2的接口分配启用了MPLS和标签协议后,会在R2上出现如下的系统提示信息:
*Jun 3 15:32:20.371: %LDP-5-NBRCHG: LDP Neighbor 10.1.1.1:0 is UP
*Jun 3 15:32:31.823: %LDP-5-NBRCHG: LDP Neighbor 10.1.1.3:0 is UP
11、在R1和R2的接口查看MPLS的接口工作信息。
R3#show mpls interfaces
Interface IP Tunnel Operational
Serial1/0 Yes (ldp) No Yes
Serial1/1 Yes (ldp) No Yes
R2#show mpls interfaces
Interface IP Tunnel Operational
Serial1/1 Yes (ldp) No Yes
R2#
12、在R3上查看LDP的邻居信息:
R3#show mpls ldp neighbor
Peer LDP Ident: 10.1.1.1:0; Local LDP Ident 10.1.1.2:0
TCP connection: 10.1.1.1.646 - 10.1.1.2.40796
State: Oper; Msgs sent/rcvd: 157/158; Downstream
Up time: 01:51:43
LDP discovery sources:
Serial1/0, Src IP addr: 10.1.10.1
Addresses bound to peer LDP Ident:
192.168.1.2 10.1.10.1 10.1.1.1
Peer LDP Ident: 10.1.1.3:0; Local LDP Ident 10.1.1.2:0
TCP connection: 10.1.1.3.18305 - 10.1.1.2.646
State: Oper; Msgs sent/rcvd: 155/157; Downstream
Up time: 01:51:32
LDP discovery sources:
Serial1/1, Src IP addr: 10.1.20.2
Addresses bound to peer LDP Ident:
10.1.20.2 172.16.1.1 10.1.1.3
R3#
13、查看R3的LDP标签信息库,即MPLS的LDP生成的LIB。
R3#show mpls ldp bindings
…………
tib entry: 172.16.1.0/24, rev 20
local binding: tag: 21
remote binding: tsr: 10.1.1.3:0, tag: imp-null
remote binding: tsr: 10.1.1.1:0, tag: 21
tib entry: 172.16.2.0/24, rev 34
local binding: tag: 20
remote binding: tsr: 10.1.1.3:0, tag: 20
remote binding: tsr: 10.1.1.1:0, tag: 20
tib entry: 192.168.1.0/24, rev 17
local binding: tag: 18
remote binding: tsr: 10.1.1.1:0, tag: imp-null
remote binding: tsr: 10.1.1.3:0, tag: 21
tib entry: 192.168.2.0/24, rev 32
local binding: tag: 19
remote binding: tsr: 10.1.1.1:0, tag: 19
remote binding: tsr: 10.1.1.3:0, tag: 19
…………
R2#
14、查看R4的LIB。
R4#show mpls ldp bindings
…………
tib entry: 172.16.2.0/24, rev 34
local binding: tag: 20
remote binding: tsr: 10.1.1.2:0, tag: 20
tib entry: 192.168.1.0/24, rev 18
local binding: tag: 21
remote binding: tsr: 10.1.1.2:0, tag: 18
tib entry: 192.168.2.0/24, rev 32
local binding: tag: 19
remote binding: tsr: 10.1.1.2:0, tag: 19
…………
R2#
15、查看R2、R3和R4的FLIB,即标签转发信息库。
R2#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 10.1.1.2/32 0 Se1/1 point2point
17 16 10.1.1.3/32 0 Se1/1 point2point
18 Pop tag 10.1.20.0/24 0 Se1/1 point2point
19 Untagged 192.168.2.0/24 0 Se1/0 point2point
20 20 172.16.2.0/24 0 Se1/1 point2point
21 21 172.16.1.0/24 0 Se1/1 point2point
R2#
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 10.1.1.3/32 0 Se1/1 point2point
17 Pop tag 10.1.1.1/32 0 Se1/0 point2point
18 Pop tag 192.168.1.0/24 0 Se1/0 point2point
19 19 192.168.2.0/24 0 Se1/0 point2point
20 20 172.16.2.0/24 0 Se1/1 point2point
21 Pop tag 172.16.1.0/24 0 Se1/1 point2point
R3#
R4#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 10.1.10.0/24 0 Se1/0 point2point
17 Pop tag 10.1.1.2/32 0 Se1/0 point2point
18 17 10.1.1.1/32 0 Se1/0 point2point
19 19 192.168.2.0/24 0 Se1/0 point2point
20 Untagged 172.16.2.0/24 0 Se1/1 point2point
21 18 192.168.1.0/24 0 Se1/0 point2point
R4#
14、使用标签进行路由的简单过程:
1) R4收到一个需要到达192.168.1.0/24网络的数据包
2) R4检查本地的FLIB后,为数据包打上18的标签,编号为18标签为上游邻居通告的,即R3路由器。
3)根据FLIB,R4从s1/0的接口转发被打上标签的数据包。
4)R3路由器收到一个被打上标签为18的数据包。
5)R3检查本地FLIB后,发现针对18的标签,应该进行POP的标签剥离。
6) R3剥离标签后,将IP数据包按FLIB所示从本地s1/0接口转发出去。
7) R2收到一个没有打标签的数据包,R2查询IP路由表,确定下一跳为192.168.1.1。
8) R2根据IP路由表,将数据包转发给下一跳路由器192.168.1.1。
9) 结束。
15、查看一些关于MPLS的LDP的参数信息。
R2#show mpls ldp parameters
Protocol version: 1
Downstream label generic region: min label: 16; max label: 100000
Session hold time: 180 sec; keep alive interval: 60 sec
Discovery hello: holdtime: 15 sec; interval: 5 sec
Discovery targeted hello: holdtime: 90 sec; interval: 10 sec
Downstream on Demand max hop count: 255
Downstream on Demand Path Vector Limit: 255
LDP for targeted sessions
LDP initial/maximum backoff: 15/120 sec
LDP loop detection: off
R2#
16、在R1上使用PING命令,确认网络。
R1#ping 172.16.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 240/293/336 ms
R1#
17、实验完成。