我们在做路由重新分布的的时候,时常由于AD距离的不同导致路由出现环路或者导致不正确的路由,那这篇文章我就好好说下这个问题,如图所示:
我们先按正常的分配方法做下看看问题在哪
我们现在r3 r4 上重新分配 命令如下
r3(config)#router rip
r3(config-router)#reis
r3(config-router)#redis
r3(config-router)#redistribute ospf 1 me
r3(config-router)#redistribute ospf 1 metric 2
r3(config-router)#redistribute ospf 1 metric 2 su
r3(config-router)#redistribute ospf 1 metric 2 subnets
r3(config-router)#redistribute rip metric 100 sub
r3(config-router)#redistribute rip metric 100 subnets metric-ty 2
r4(config)#router rip
r4(config-router)#redis
r4(config-router)#redistribute ospf 1 me
r4(config-router)#redistribute ospf 1 metric ?
<0-16> Default metric
transparent Transparently redistribute metric
r4(config-router)#redistribute rip metric 100 me
r4(config-router)#redistribute rip metric 100 metric-type 2 sub
r4#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
O 192.168.4.0/24 [110/74] via 192.168.3.1, 00:02:04, Serial0/0
O 192.168.5.0/24 [110/138] via 192.168.3.1, 00:02:04, Serial0/0
O E2 192.168.6.0/24 [110/100] via 192.168.3.1, 00:02:04, Serial0/0
O E2 192.168.1.0/24 [110/100] via 192.168.3.1, 00:02:04, Serial0/0
C 192.168.2.0/24 is directly connected, Ethernet1/0
C 192.168.3.0/24 is directly connected, Serial0/0
我们看下r4的路由表发现通往0.6网段吓一跳是192.168.3.1 跳到r1上面去了,这并不是最佳路由,为什么会发生这样的问题?是管理距离惹得祸,我们知道ospf管理距离是90。而rip是120,所以路由会优先选用ospf路由条目,这就给我们一个警示:在多点路由重新分配时管理距离会导致非最佳路径的选择,路由环路和黑洞。
那我们该咋样做那,有两种方法一是运用重发布列表控制路由更新
法二:用distance控制管理距离
我们先看第一种方法
我们在r3 r4 做如下配置
r3 :r3(config-router)#redistribute rip metric 100 sub
r3(config-router)#net
r3(config-router)#network 192.168.3.0 0.0.0.255 a 0
r3(config-router)#dis
r3(config-router)#distri
r3(config-router)#distribute-list 1 in
r3(config-router)#router rip
r3(config-router)#redtri
r3(config-router)#redis
r3(config-router)#redistribute ospf 1 me
r3(config-router)#redistribute ospf 1 metric 2
r3(config-router)#net
r3(config-router)#network 192.168.6.0
r3(config-router)#distri
r3(config-router)#distribute-list 2 in
r3(config-router)#ip cl
r3(config-router)#ip cl
r3(config)#acc
r3(config)#access-list 1 per
r3(config)#access-list 1 permit 192.168.4.0
r3(config)#access-list 1 permit 192.168.3.0
r4;r4(config)#router rip
r4(config-router)#redis
r4(config-router)#redistribute ospf 1 me
r4(config-router)#redistribute ospf 1 metric 2
r4(config-router)#net
r4(config-router)#network 192.168.2.0 0.0.0.
^
% Invalid input detected at '^' marker.
r4(config-router)#network 192.168.2.0 0.0.0.255
^
% Invalid input detected at '^' marker.
r4(config-router)#network 192.168.2.0
r4(config-router)#distri
r4(config-router)#distribute-list 1 in
r4(config-router)#router ospf 1
r4(config-router)#red
r4(config-router)#redistribute rip me
r4(config-router)#redistribute rip metric 100 sub
r4(config-router)#net
r4(config-router)#network 192.168.3.0 0.0.0.255 a 0
r4(config-router)#distri
r4(config-router)#distribute-list 2 in
r4(config-router)#ip cl
r4(config)#acc
r4(config)#access-list 1 per 192.168.1.0
r4(config)#acc
r4(config)#access-list 1 per 192.168.6.0
r4(config)#acc
r4(config)#access-list 2 per 192.166.4.0
r4(config)#access-list 2 per 192.168.4.0
r4(config)#access-list 2 per 192.168.5.0
我们在show下
r4#show ip ro
r4#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
O 192.168.4.0/24 [110/74] via 192.168.3.1, 00:00:21, Serial0/0
O 192.168.5.0/24 [110/138] via 192.168.3.1, 00:00:21, Serial0/0
R 192.168.6.0/24 [120/1] via 192.168.2.5, 00:00:11, Ethernet1/0
R 192.168.1.0/24 [120/1] via 192.168.2.5, 00:00:11, Ethernet1/0
C 192.168.2.0/24 is directly connected, Ethernet1/0
C 192.168.3.0/24 is directly connected, Serial0/0
发现192.168.6.0 吓一跳为192.168.2.5 了 成功
法2:用distance改变管理距离
r3(config)#router ospf 1
r3(config-router)#red
r3(config-router)#redistribute rip me
r3(config-router)#redistribute rip metric 100 sub
r3(config-router)#net
r3(config-router)#network 192.168.5.0 0.0.0.255 a 0
r3(config-router)#dis
r3(config-router)#distan
r3(config-router)#distance 130
r3(config-router)#distan
r3(config-router)#distance 110 0.0.0.0 255.255.255.0 1
r3(config-router)#rout
r3(config-router)#router rip
r3(config-router)#redis
r3(config-router)#redistribute ospf 1 me
r3(config-router)#redistribute ospf 1 metric 2
r3(config-router)#net
r3(config-router)#network 192.168.6.0
r3(config-router)#dis
r3(config-router)#distan
r3(config-router)#distance 130
r3(config-router)#distan
r3(config-router)#distance 120 192.168.6.3 2
r3(config)#access-list 1 per 192.168.4.0
r3(config)#access-list 1 per 192.168.5.0
r3(config)#access-list 2 per 192.168.6.0
r3(config)#access-list 2 per 192.168.1.0
r4(config-router)#redistribute rip me
r4(config-router)#redistribute rip metric 100 sub
r4(config-router)#net
r4(config-router)#network 192.168.3.0 0.0.0.255 a 0
r4(config-router)#distan
r4(config-router)#distance 130
r4(config-router)#distance 110 0.0.0.0 255.255.255.255 1
r4(config-router)#router rip
r4(config-router)#red
r4(config-router)#redistribute ospf 1 me
r4(config-router)#redistribute ospf 1 metric 2
r4(config-router)#net
r4(config-router)#network 192.168.2.0
r4(config-router)#dis
r4(config-router)#distan
r4(config-router)#distance 130
r4(config-router)#distan
r4(config-router)#distance 120 192.168.2.4 2
% Incomplete command.
r4(config-router)#distance 120 192.168.2.4 0.0.0.255 2
r4(config-router)#ip cl
r4(config)#ac
r4(config)#access-list 1 per 192.168.4.0
r4(config)#access-list 1 per 192.168.5.0
r4(config)#access-list 2 per 192.168.1.0
r4(config)#access-list 2 per 192.168.6.0
r4#show ip ro
r4#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
O 192.168.4.0/24 [110/74] via 192.168.3.1, 00:00:21, Serial0/0
O 192.168.5.0/24 [110/138] via 192.168.3.1, 00:00:21, Serial0/0
R 192.168.6.0/24 [120/1] via 192.168.2.5, 00:00:11, Ethernet1/0
R 192.168.1.0/24 [120/1] via 192.168.2.5, 00:00:11, Ethernet1/0
C 192.168.2.0/24 is directly connected, Ethernet1/0
C 192.168.3.0/24 is directly connected, Serial0/0
成功!
本文出自 “cisco network” 博客,谢绝转载!