3路由策略_route-map(用于重分发)

简介:
拓扑图:
配置参数:
R1
access-list 1 permit 11.11.11.0 0.0.0.255
route-map connected permit 10
 match ip address 1
router rip
 version 2
 redistribute connected route-map connected
 network 192.168.1.0
 no auto-summary
R2
access-list 1 permit 3.3.3.0 0.0.0.255
access-list 2 permit 23.23.23.0 0.0.0.255
route-map ospf permit 10
 match ip address 1
 set metric 1
route-map ospf permit 20
 match ip address 2
 set metric 2
router ospf 1
redistribute rip subnets
 network 192.168.2.0 0.0.0.255 area 0
router rip
 version 2
 redistribute ospf 1 route-map ospf
 network 192.168.1.0
 no auto-summary
查看配置效果:
R2:
r2#sh ip rou
Gateway of last resort is not set
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.168.2.2, 00:13:16, Serial0/1
     23.0.0.0/32 is subnetted, 1 subnets
O       23.23.23.23 [110/65] via 192.168.2.2, 00:13:16, Serial0/1
     11.0.0.0/24 is subnetted, 1 subnets
R       11.11.11.0 [120/1] via 192.168.1.1, 00:00:17, Serial0/0
C    192.168.1.0/24 is directly connected, Serial0/0
C    192.168.2.0/24 is directly connected, Serial0/1
r2#
从上面可以看出 R2 只学习到了 R1 1 条直连路由( 11.11.11.0/24
R1:
r1#sh ip rou
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
R       3.3.3.3 [120/1] via 192.168.1.2, 00:00:07, Serial0/0
     23.0.0.0/32 is subnetted, 1 subnets
R       23.23.23.23 [120/2] via 192.168.1.2, 00:00:07, Serial0/0
     11.0.0.0/24 is subnetted, 1 subnets
C       11.11.11.0 is directly connected, Loopback1
C    192.168.1.0/24 is directly connected, Serial0/0
r1#
从上面可以看出 R1 学习到了 3.3.3.0/24 这条路由的路数为 1 ,学习到 23.23.23.0/24 这条路由为 2 跳!!!实验配置成功!!!

拓扑图2:
配置参数:
R1 上先不要配置 111.111.111.111 这条,先配置好下面参数,等一下测试要用到。
R1:
access-list 1 permit 1.1.1.0 0.0.0.255  //ACL 在这里用来匹配流量(只匹配 1.1.1.0/24 ),然后在 route-map 中配置为只有 1.1.1.0/24 这条路由不匹配(不被重发布,使 R2 不能学习),其它路由则匹配(可以被重发布,使 R2 可以学习到)
route-map connected deny 10 // 设置不匹配参数
 match ip address 1  // 设置不匹配的流量为访问列表 1
route-map connected permit 20 // 设置其它路由匹配(允许重发布)
router rip
 version 2
 redistribute connected route-map connected  // RIP 重发布直连路由时应用上面配置的路由图 connected
 network 192.168.1.0
 no auto-summary
R2 :与上个拓扑图配置一样。
查看配置效果:
R2:
r2#sh ip rou
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.168.2.2, 00:25:40, Serial0/1
     23.0.0.0/32 is subnetted, 1 subnets
O       23.23.23.23 [110/65] via 192.168.2.2, 00:25:40, Serial0/1
     11.0.0.0/24 is subnetted, 1 subnets
R       11.11.11.0 [120/1] via 192.168.1.1, 00:00:11, Serial0/0
C    192.168.1.0/24 is directly connected, Serial0/0
C    192.168.2.0/24 is directly connected, Serial0/1
r2#
可以看出了 R2 没有学习到 1.1.1.1/24 这条路由,而学习到了 11.11.11.11/24 这条路由。从上面 R1 的配置中,说明 R2 可以学习到除了 1.1.1.1/24 这条路由的其它路由,在这里我样可以测试一下:
现在在 R1 上配置一条 111.111.111.111/24 的路由,可以发现 R2 马上就可以学习到,如果是按照上一个拓扑图那样配置的话, R2 是学习不到的。
R1:
r1(config)#int l2
r1(config-if)#ip add 111.111.111.111 255.255.255.0
r1(config-if)#no sh
r1(config-if)#
查看配置效果:
R2
r2#sh ip rou
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.168.2.2, 00:29:29, Serial0/1
     23.0.0.0/32 is subnetted, 1 subnets
O       23.23.23.23 [110/65] via 192.168.2.2, 00:29:29, Serial0/1
     111.0.0.0/24 is subnetted, 1 subnets
R       111.111.111.0 [120/1] via 192.168.1.1, 00:00:18, Serial0/0
     11.0.0.0/24 is subnetted, 1 subnets
R       11.11.11.0 [120/1] via 192.168.1.1, 00:00:18, Serial0/0
C    192.168.1.0/24 is directly connected, Serial0/0
C    192.168.2.0/24 is directly connected, Serial0/1
r2#
看到了吧, R2 马上就学习到了!!!



      本文转自810105851 51CTO博客,原文链接:http://blog.51cto.com/4708948/1130318 ,如需转载请自行联系原作者






相关文章
|
7月前
|
安全 Java 数据库连接
让我们讲解一下 Map 集合遍历的方式
我是小假 期待与你的下一次相遇 ~
283 43
Dart之集合详解(List、Set、Map)
Dart之集合详解(List、Set、Map)
187 1
|
10月前
使用 entrySet 遍历 Map 类集合 KV
使用 entrySet 遍历 Map 类集合 KV
|
存储 前端开发 API
ES6的Set和Map你都知道吗?一文了解集合和字典在前端中的应用
该文章详细介绍了ES6中Set和Map数据结构的特性和使用方法,并探讨了它们在前端开发中的具体应用,包括如何利用这些数据结构来解决常见的编程问题。
ES6的Set和Map你都知道吗?一文了解集合和字典在前端中的应用
|
存储 安全 Java
java集合框架复习----(4)Map、List、set
这篇文章是Java集合框架的复习总结,重点介绍了Map集合的特点和HashMap的使用,以及Collections工具类的使用示例,同时回顾了List、Set和Map集合的概念和特点,以及Collection工具类的作用。
java集合框架复习----(4)Map、List、set
|
Go 定位技术 索引
Go 语言Map(集合) | 19
Go 语言Map(集合) | 19
【Java集合类面试二十二】、Map和Set有什么区别?
该CSDN博客文章讨论了Map和Set的区别,但提供的内容摘要并未直接解释这两种集合类型的差异。通常,Map是一种键值对集合,提供通过键快速检索值的能力,而Set是一个不允许重复元素的集合。