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 ,如需转载请自行联系原作者






  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值