步骤一:
R1
在相应的接口配上IP地址,并创建一个回环口loop 0 1.1.1.1/24
router rip
version 2
redistribute connected metric 5(将lo:0 重分发到rip中metric值为5)
network 126.126.0.0
no auto-summary
R2
在相应的接口配上IP地址
router rip
version 2
network 126.126.0.0
no auto-summary
router ospf 1
network 24.24.24.2 0.0.0.0 area 0
R3
在相应的接口配上IP地址
router rip
version 2
redistribute ospf 1 metric 4
network 126.126.0.0
no auto-summary
router ospf 1
network 34.34.34.3 0.0.0.0 area 0
R4
在相应的接口配上IP地址,并创建一个回环口loop 0 2.2.2.2/24
router ospf 1
network 4.4.4.4 0.0.0.0 area 0
network 24.24.24.4 0.0.0.0 area 0
network 34.34.34.4 0.0.0.0 area 0
步骤二:
在R3上
R3#sh ip rout
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
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/5] via 126.126.127.1, 00:00:25, Ethernet0/1(可看出1.1.1.1的路由是从126.126.127.1 学来的。
在R2上
R2#sh ip rout
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
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/5] via 126.126.126.1, 00:00:25, Ethernet0/1(可看出1.1.1.1的路由是从126.126.126.1 学来的。)
在R2上做rip到ospf的重分发
R2
redistribute rip subnets
查看R3的路由表
R3#sh ip rou
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
C 34.34.34.0 is directly connected, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 34.34.34.4, 00:00:40, Serial1/0(可看出1.1.1.1的路由是从34.34.34.4 学来的。)
查看R2的路由表
在R3上
R2#sh ip rout
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
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/5] via 126.126.126.1, 00:00:25, Ethernet0/1(可看出1.1.1.1的路由还是从126.126.126.1 学来的。)
因此就出现了次优路由路径
在R3上再配置从ospf到rip的重分发。并配置metric值为4
R3
router rip
redistribute ospf 1 metric 4
在查看R2的路由表
R2#sh ip rou
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.34.34.0 [110/128] via 24.24.24.4, 00:00:05, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/4] via 126.126.128.2, 00:00:05, Ethernet0/2(到1.1.1.1的路由的metric变成4了。它从126.126.128.2 学到的路由。)
因此从R2,R3 ping 1.1.1.1 是ping必到的。这就成了环路。
R3#tr 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 34.34.34.4 20 msec 20 msec 24 msec
2 24.24.24.2 40 msec 40 msec 20 msec
3 126.126.128.2 56 msec 52 msec 48 msec
4 34.34.34.4 52 msec 60 msec 48 msec
5 24.24.24.2 52 msec 64 msec 76 msec
6 126.126.128.2 100 msec 84 msec 80 msec
7 34.34.34.4 76 msec 84 msec 80 msec
8 24.24.24.2 80 msec 100 msec 104 msec
9 126.126.128.2 128 msec 108 msec 112 msec
10 34.34.34.4 108 msec 112 msec 112 msec
11 24.24.24.2 108 msec 140 msec 132 msec
12 126.126.128.2 156 msec 140 msec 144 msec
13 34.34.34.4 140 msec 140 msec 140 msec
14 24.24.24.2 144 msec 156 msec 164 msec
15 126.126.128.2 192 msec 172 msec 176 msec
16 34.34.34.4 176 msec 172 msec 180 msec
17 24.24.24.2 164 msec 192 msec 192 msec
18 126.126.128.2 220 msec 200 msec 200 msec
19 34.34.34.4 200 msec 200 msec 204 msec
20 24.24.24.2 236 msec 196 msec 220 msec
21 126.126.128.2 252 msec 228 msec 232 msec
22 34.34.34.4 224 msec 240 msec 224 msec
23 24.24.24.2 232 msec 264 msec 256 msec
24 126.126.128.2 268 msec 260 msec 264 msec
25 34.34.34.4 260 msec 260 msec 264 msec
26 24.24.24.2 260 msec 292 msec 280 msec
27 126.126.128.2 312 msec 288 msec 292 msec
28 34.34.34.4 292 msec 292 msec 300 msec
29 24.24.24.2 292 msec 316 msec 308 msec
30 126.126.128.2 344 msec 324 msec 320 msec
R2#tr 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 34.34.34.4 20 msec 20 msec 24 msec
2 24.24.24.2 40 msec 40 msec 20 msec
3 126.126.128.2 56 msec 52 msec 48 msec
4 34.34.34.4 52 msec 60 msec 48 msec
5 24.24.24.2 52 msec 64 msec 76 msec
6 126.126.128.2 100 msec 84 msec 80 msec
7 34.34.34.4 76 msec 84 msec 80 msec
8 24.24.24.2 80 msec 100 msec 104 msec
9 126.126.128.2 128 msec 108 msec 112 msec
10 34.34.34.4 108 msec 112 msec 112 msec
11 24.24.24.2 108 msec 140 msec 132 msec
12 126.126.128.2 156 msec 140 msec 144 msec
13 34.34.34.4 140 msec 140 msec 140 msec
14 24.24.24.2 144 msec 156 msec 164 msec
15 126.126.128.2 192 msec 172 msec 176 msec
16 34.34.34.4 176 msec 172 msec 180 msec
17 24.24.24.2 164 msec 192 msec 192 msec
18 126.126.128.2 220 msec 200 msec 200 msec
19 34.34.34.4 200 msec 200 msec 204 msec
20 24.24.24.2 236 msec 196 msec 220 msec
21 126.126.128.2 252 msec 228 msec 232 msec
22 34.34.34.4 224 msec 240 msec 224 msec
23 24.24.24.2 232 msec 264 msec 256 msec
24 126.126.128.2 268 msec 260 msec 264 msec
25 34.34.34.4 260 msec 260 msec 264 msec
26 24.24.24.2 260 msec 292 msec 280 msec
27 126.126.128.2 312 msec 288 msec 292 msec
28 34.34.34.4 292 msec 292 msec 300 msec
29 24.24.24.2 292 msec 316 msec 308 msec
30 126.126.128.2 344 msec 324 msec 320 msec
结论:当我们从管理距离小的协议重分发到管理距离大的时候,没有问题;反之则会产生环路或产生次优路由。
原文地址:http://mokaka.blog.51cto.com/10063775/1633881