设为首页 收藏本站
查看: 1555|回复: 0

[经验分享] 【CCNP】路由策略:管理距离控制路由走向(解决次优路径)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-9-9 08:38:31 | 显示全部楼层 |阅读模式
实验拓扑:
wKioL1QLrYjSWubjAAFR1F2EAJA800.jpg
如图,属于ospf中的双点双向重分发,上面方框表示运行的是ospf协议,下面方框表示运行的是RIP协议。
实验目的:1.将RIP和OSPF互相重分发,观察会发生什么问题
          2.通过改变管理距离,解决次优路径问题
实验步骤:
  • 首先完成基本配置
R1
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/1
R1(config-if)#ip add 10.1.12.1 255.255.255.0
R1(config-if)#no sh

R1(config-if)#int f0/0
R1(config-if)#ip add 10.1.13.1 255.255.255.0
R1(config-if)#no sh

R1(config-if)#int l0                        
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#no sh
R1(config-if)#ex

R2
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

R2(config)#int f0/0
R2(config-if)#ip add 10.1.12.2 255.255.255.0
R2(config-if)#no sh

R2(config-if)#int f0/1
R2(config-if)#ip add 10.1.24.2 255.255.255.0
R2(config-if)#no sh

R2(config-if)#int l0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#no sh
R2(config-if)#ex

R3

R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config-if)#int f0/1
R3(config-if)#ip add 10.1.13.3 255.255.255.0
R3(config-if)#no sh

R3(config-if)#int f0/0
R3(config-if)#ip add 10.1.34.3 255.255.255.0
R3(config-if)#no sh

R3(config-if)#int l0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#no sh
R3(config-if)#ex

R4
R4#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#int l0
R4(config-if)#ip add 4.4.4.4 255.255.255.255
R4(config-if)#no sh

R4(config-if)#int f0/0
R4(config-if)#ip add 10.1.24.4 255.255.255.0
R4(config-if)#no sh

R4(config-if)#int f0/1
R4(config-if)#ip add 10.1.34.4 255.255.255.0
R4(config-if)#no sh
R4(config-if)#ex

接着在R1,R2,R3上运行OSPF ,在R2,R3,R4上运行RIP,注意宣告网段时候不要重叠。

R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 1.1.1.1 0.0.0.0 a 1
R1(config-router)#network 10.1.12.0 0.0.0.255 a 1
R1(config-router)#network 10.1.13.0 0.0.0.255 a 1

R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 10.1.12.0 0.0.0.255 a 1
R2(config-router)#network 10.1.12.0 0.0.0.255 a 1
R2(config-router)#ex


R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 10.1.13.0 0.0.0.255 a 1
R3(config-router)#ex
R3(config)#end

R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#network 10.0.0.0

R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#network 10.0.0.0
R3(config-router)#ex

R4(config)#router rip
R4(config-router)#version 2
R4(config-router)#no auto-summary
R4(config-router)#network 4.4.4.4
R4(config-router)#network 10.0.0.0

此时,在R3上show ip route,观察去往4.4.4.4的路由走向

R3#show ip route
.......
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/11] via 10.1.13.1, 00:02:01, FastEthernet0/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
R       4.4.4.4 [120/1] via 10.1.34.4, 00:00:05, FastEthernet0/0
     10.0.0.0/24 is subnetted, 4 subnets
C       10.1.13.0 is directly connected, FastEthernet0/1
O       10.1.12.0 [110/20] via 10.1.13.1, 00:02:01, FastEthernet0/1
R       10.1.24.0 [120/1] via 10.1.34.4, 00:00:07, FastEthernet0/0
C       10.1.34.0 is directly connected, FastEthernet0/0
发现是直接通过RIP从R4的f0/1走的,没问题。

2.路由重分发

这时候,在R2,R3上将ospf重分发入rip

R2(config)#router rip
R2(config-router)#redistribute ospf 1 metric 2

R3(config)#router rip
R3(config-router)#redistribute ospf 1 metric 2

注意:将ospf注入rip时,要加上度量值metric,否则默认不可达。
这时候,继续在R3上show ip route
R3#show ip route
........


     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/11] via 10.1.13.1, 00:18:38, FastEthernet0/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
R       4.4.4.4 [120/1] via 10.1.34.4, 00:00:07, FastEthernet0/0
     10.0.0.0/24 is subnetted, 4 subnets
C       10.1.13.0 is directly connected, FastEthernet0/1
O       10.1.12.0 [110/20] via 10.1.13.1, 00:18:38, FastEthernet0/1
R       10.1.24.0 [120/1] via 10.1.34.4, 00:00:08, FastEthernet0/0
C       10.1.34.0 is directly connected, FastEthernet0/0
依然是没问题的。

在R2上将RIP注入ospf
R2(config)#router ospf 1
R2(config-router)#redistribute rip subnets

这时候,在R3上查看路由表
R3#show ip route
.....
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/11] via 10.1.13.1, 00:00:05, FastEthernet0/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 E2    4.4.4.4 [110/20] via 10.1.13.1, 00:00:05, FastEthernet0/1
     10.0.0.0/24 is subnetted, 4 subnets
C       10.1.13.0 is directly connected, FastEthernet0/1
O       10.1.12.0 [110/20] via 10.1.13.1, 00:00:05, FastEthernet0/1
O E2    10.1.24.0 [110/20] via 10.1.13.1, 00:00:07, FastEthernet0/1
C       10.1.34.0 is directly connected, FastEthernet0/0

因为ospf的AD值小于RIP,所以在R3上去往4.4.4.4会优先选择ospf的路径,就是R3—R1—R2—R4这条路,明明只需要走R3—R4这条路,却需要走一大圈,这就是所谓的次优路径,在现网中会造成大量的路由资源浪费。

并且,在R3上将RIP重分发入ospf也会失败,因为,在R3路由表中的RIP路由已经被ospf覆盖,重分发路由是要以路由表中存在路由作为前提。

那么如何解决这种问题?可以通过修改AD值来控制路由的走向。

3.修改AD值,解决次优路径

首先做一个ACL访问列表允许目标网段
R3(config)#access-list 1 permit 4.4.4.4

在RIP中修改RIP到达R4的AD值为100(小于ospf),并且应用ACL

R3(config)#router rip
R3(config-router)#distance 100 10.1.34.4 0.0.0.255 1
R3(config-router)#end

R3#clear ip route *         清空下路由表

R3#show ip route   
.......

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/11] via 10.1.13.1, 00:00:01, FastEthernet0/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
R       4.4.4.4 [100/1] via 10.1.34.4, 00:00:01, FastEthernet0/0
     10.0.0.0/24 is subnetted, 4 subnets
C       10.1.13.0 is directly connected, FastEthernet0/1
O       10.1.12.0 [110/20] via 10.1.13.1, 00:00:01, FastEthernet0/1
O E2    10.1.24.0 [110/20] via 10.1.13.1, 00:00:02, FastEthernet0/1
C       10.1.34.0 is directly connected, FastEthernet0/0

经过调整,发现路由已经正常了。
在R2上也要做一样的修改,否则R2去往4.4.4.4也会出现次优路径

R2(config)#access-list 1 permit 4.4.4.4
R2(config)#router rip
R2(config-router)#distance 100 10.1.24.4 0.0.0.255 1
R2(config-router)#end

在R3上也将RIP重分发入ospf
R3(config)#router rip
R3(config-router)#redistribute rip subnets
R3(config-router)#end                 

最后在R1上查看去往R4的环回口4.4.4.4是否正常
R1#clear ip route *
R1#show ip route   
......

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O E2    4.4.4.4 [110/20] via 10.1.13.3, 00:00:01, FastEthernet0/0
                [110/20] via 10.1.12.2, 00:00:01, FastEthernet0/1
     10.0.0.0/24 is subnetted, 4 subnets
C       10.1.13.0 is directly connected, FastEthernet0/0
C       10.1.12.0 is directly connected, FastEthernet0/1
O E2    10.1.24.0 [110/20] via 10.1.12.2, 00:00:01, FastEthernet0/1
O E2    10.1.34.0 [110/20] via 10.1.13.3, 00:00:02, FastEthernet0/0

负载均衡,没有问题,实验结束。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-24571-1-1.html 上篇帖子: CCNA学习指南 第三章 下载 下篇帖子: CCNP路由实验之四 动态路由协议之EIGRP CCNP
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表