实验过程:
第一步 R1、R2、R3、R4、R5的预配置
R1(config)#
int lo0
R1(config-if)#
ip add 1.1.1.1 255.255.255.0
R1(config-if)#
int s2/1
R1(config-if)#
ip add 12.0.0.1 255.255.255.0
R1(config-if)#
no sh
R1(config-if)#
exit
R2(config)#
int lo0
R2(config-if)#
ip add 2.2.2.2 255.255.255.0
R2(config-if)#
int s2/1
R2(config-if)#
ip add 12.0.0.2 255.255.255.0
R2(config-if)#
no sh
R2(config-if)#
int s2/2
R2(config-if)#
ip add 23.0.0.2 255.255.255.0
R2(config-if)#
no sh
R2(config-if)#
exit
R3(config)#
int lo0
R3(config-if)#
ip add 3.3.3.3 255.255.255.0
R3(config-if)#
int s2/1
R3(config-if)#
ip add 23.0.0.3 255.255.255.0
R3(config-if)#
no sh
R3(config-if)#
int s2/2
R3(config-if)#
ip add 34.0.0.3 255.255.255.0
R3(config-if)#
no sh
R3(config-if)#
exit
R4(config)#
int lo0
R4(config-if)#
ip add 4.4.4.4 255.255.255.0
R4(config-if)#
int s2/1
R4(config-if)#
ip add 34.0.0.4 255.255.255.0
R4(config-if)#
no sh
R4(config-if)#
int s2/2
R4(config-if)#
ip add 45.0.0.4 255.255.255.0
R4(config-if)#
no sh
R4(config-if)#
exit
R5(config)#
int lo0
R5(config-if)#
ip add 5.5.5.5 255.255.255.0
R5(config-if)#
int s2/2
R5(config-if)#
ip add 45.0.0.5 255.255.255.0
R5(config-if)#
no sh
R5(config-if)#
exit
第二步 在R1、R2、R3、R4、R5上配置OSPF
R1(config)#
router ospf 64
R1(config-router)#
net 0.0.0.0 0.0.0.0 a 0
R1(config-router)#
end
R2(config)#
router ospf 64
R2(config-router)#
net 0.0.0.0 0.0.0.0 a 0
R2(config-router)#
end
R3(config)#
router ospf 64
R3(config-router)#
net 0.0.0.0 0.0.0.0 a 0
R3(config-router)#
end
R4(config)#
router ospf 64
R4(config-router)#
net 0.0.0.0 0.0.0.0 a 0
R4(config-router)#
end
R5(config)#
router ospf 64
R5(config-router)#
net 0.0.0.0 0.0.0.0 a 0
R5(config-router)#
end
第三步 查看R1的路由表
R1#
show ip route
Codes: 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
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
O 34.0.0.0 [110/192] via 12.0.0.2, 00:01:17, Serial2/1
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.0.0.2, 00:01:17, Serial2/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/129] via 12.0.0.2, 00:01:17, Serial2/1
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/193] via 12.0.0.2, 00:01:17, Serial2/1
5.0.0.0/32 is subnetted, 1 subnets
O 5.5.5.5 [110/257] via 12.0.0.2, 00:01:17, Serial2/1
23.0.0.0/24 is subnetted, 1 subnets
O 23.0.0.0 [110/128] via 12.0.0.2, 00:01:18, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
45.0.0.0/24 is subnetted, 1 subnets
O 45.0.0.0 [110/256] via 12.0.0.2, 00:01:18, Serial2/1
R1#
第四步 查看CEF
R1#
show ip cef
Prefix Next Hop Interface
0.0.0.0/0 drop Null0 (default route handler entry)
0.0.0.0/32 receive
1.1.1.0/24 attached Loopback0
1.1.1.0/32 receive
1.1.1.1/32 receive
1.1.1.255/32 receive
2.2.2.2/32 12.0.0.2 Serial2/1
3.3.3.3/32 12.0.0.2 Serial2/1
4.4.4.4/32 12.0.0.2 Serial2/1
5.5.5.5/32 12.0.0.2 Serial2/1
12.0.0.0/24 attached Serial2/1
12.0.0.0/32 receive
12.0.0.1/32 receive
12.0.0.255/32 receive
23.0.0.0/24 12.0.0.2 Serial2/1
34.0.0.0/24 12.0.0.2 Serial2/1
45.0.0.0/24 12.0.0.2 Serial2/1
224.0.0.0/4 drop
224.0.0.0/24 receive
255.255.255.255/32 receive
第五步 配置R1、R2、R3、R4、R5的MPLS
R1(config)#
mpls label range 100 199
R1(config)#
mpls label protocol ldp
R1(config)#
int s2/1
R1(config-if)#
mpls ip
R1(config-if)#
end
R2(config)#
mpls label range 200 299
R2(config)#
mpls label protocol ldp
R2(config)#
int s2/1
R2(config-if)#
mpls ip
R2(config-if)#
int s2/2
R2(config-if)#
mpls ip
R2(config-if)#
end
R3(config)#
mpls label range 300 399
R3(config)#
mpls label protocol ldp
R3(config)#
int s2/1
R3(config-if)#
mpls ip
R3(config-if)#
int s2/2
R3(config-if)#
mpls ip
R3(config-if)#
end
R4(config)#
mpls label range 400 499
R4(config)#
mpls label protocol ldp
R4(config)#
int s2/1
R4(config-if)#
mpls ip
R4(config-if)#
int s2/2
R4(config-if)#
mpls ip
R4(config-if)#
end
R5(config)#
mpls label range 500 599
R5(config)#
mpls label protocol ldp
R5(config)#
int s2/2
R5(config-if)#
mpls ip
R5(config-if)#
end
第六步 检查R1的MPLS配置效果
R1#
show mpls interfaces
Interface IP Tunnel Operational
Serial2/1 Yes (ldp) No Yes
R1#
show mpls interfaces detail
Interface Serial2/1:
IP labeling enabled (ldp):
Interface config
LSP Tunnel labeling not enabled
BGP tagging not enabled
Tagging operational
Fast Switching Vectors:
IP to MPLS Fast Switching Vector
MPLS Turbo Vector
MTU = 1500
R1#
show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
100 200 34.0.0.0/24 0 Se2/1 point2point
101 Untagged 2.2.2.2/32 0 Se2/1 point2point
102 202 3.3.3.3/32 0 Se2/1 point2point
103 203 4.4.4.4/32 0 Se2/1 point2point
104 204 5.5.5.5/32 0 Se2/1 point2point
105 Pop tag 23.0.0.0/24 0 Se2/1 point2point
106 205 45.0.0.0/24 0 Se2/1 point2point
R1#
show mpls ldp binding
tib entry: 1.1.1.0/24, rev 4
local binding: tag: imp-null
tib entry: 1.1.1.1/32, rev 19
remote binding: tsr: 2.2.2.2:0, tag: 201
tib entry: 2.2.2.0/24, rev 20
remote binding: tsr: 2.2.2.2:0, tag: imp-null
tib entry: 2.2.2.2/32, rev 6
local binding: tag: 101
tib entry: 3.3.3.3/32, rev 8
local binding: tag: 102
remote binding: tsr: 2.2.2.2:0, tag: 202
tib entry: 4.4.4.4/32, rev 10
local binding: tag: 103
remote binding: tsr: 2.2.2.2:0, tag: 203
tib entry: 5.5.5.5/32, rev 12
local binding: tag: 104
remote binding: tsr: 2.2.2.2:0, tag: 204
tib entry: 12.0.0.0/24, rev 16
local binding: tag: imp-null
remote binding: tsr: 2.2.2.2:0, tag: imp-null
tib entry: 23.0.0.0/24, rev 14
local binding: tag: 105
remote binding: tsr: 2.2.2.2:0, tag: imp-null
tib entry: 34.0.0.0/24, rev 2
local binding: tag: 100
remote binding: tsr: 2.2.2.2:0, tag: 200
tib entry: 45.0.0.0/24, rev 18
local binding: tag: 106
remote binding: tsr: 2.2.2.2:0, tag: 205
R1#
show mpls ldp nei
Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 1.1.1.1:0
TCP connection: 2.2.2.2.36585 - 1.1.1.1.646
State: Oper; Msgs sent/rcvd: 20/20; Downstream
Up time: 00:06:57
LDP discovery sources:
Serial2/1, Src IP addr: 12.0.0.2
Addresses bound to peer LDP Ident:
12.0.0.2 23.0.0.2 2.2.2.2
R1#
show tag-switching tdp nei
// 与show mpls ldp nei效果一样
Peer LDP Ident: 2.2.2.2:0; Local LDP Ident 1.1.1.1:0
TCP connection: 2.2.2.2.36585 - 1.1.1.1.646
State: Oper; Msgs sent/rcvd: 21/20; Downstream
Up time: 00:07:38
LDP discovery sources:
Serial2/1, Src IP addr: 12.0.0.2
Addresses bound to peer LDP Ident:
12.0.0.2 23.0.0.2 2.2.2.2
第七步 在R1上运行traceroute测试
R1#
traceroute
Protocol [ip]:
Target IP address:
5.5.5.5
Source address:
1.1.1.1
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 5.5.5.5
1 12.0.0.2 [MPLS: Label 204 Exp 0] 300 msec 232 msec 112 msec
2 23.0.0.3 [MPLS: Label 303 Exp 0] 176 msec 132 msec 196 msec
3 34.0.0.4 [MPLS: Label 403 Exp 0] 184 msec 160 msec 156 msec
4 45.0.0.5 160 msec * 228 msec
第八步 检查5.5.5.5的标签分配
R1#
show mpls ldp binding 5.5.5.5 32
tib entry: 5.5.5.5/32, rev 12
local binding: tag: 104
remote binding: tsr: 2.2.2.2:0, tag: 204
R2#
show mpls ldp binding 5.5.5.5 32
tib entry: 5.5.5.5/32, rev 12
local binding: tag: 204
remote binding: tsr: 1.1.1.1:0, tag: 104
remote binding: tsr: 3.3.3.3:0, tag: 303
R3#
show mpls ldp binding 5.5.5.5 32
tib entry: 5.5.5.5/32, rev 12
local binding: tag: 303
remote binding: tsr: 2.2.2.2:0, tag: 204
remote binding: tsr: 4.4.4.4:0, tag: 403
R4#
show mpls ldp binding 5.5.5.5 32
tib entry: 5.5.5.5/32, rev 12
local binding: tag: 403
remote binding: tsr: 3.3.3.3:0, tag: 303
R5#
show mpls ldp binding 5.5.5.5 32
tib entry: 5.5.5.5/32, rev 20
remote binding: tsr: 4.4.4.4:0, tag: 403
第九步 检查5.5.5.5的MPLS转发表
R1#
show mpls forwarding-table 5.5.5.5
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
104 204 5.5.5.5/32 0 Se2/1 point2point
R2#
show mpls forwarding-table 5.5.5.5
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
204 303 5.5.5.5/32 324 Se2/2 point2point
R3#
show mpls forwarding-table 5.5.5.5
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
303 403 5.5.5.5/32 744 Se2/2 point2point
R4#
show mpls forwarding-table 5.5.5.5
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
403 Untagged 5.5.5.5/32 1128 Se2/2 point2point
// 倒数第二跳弹出
R5#
show mpls forwarding-table 5.5.5.5
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface