天天看点

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

 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

 redistribute ospf 1 route-map ospf

查看配置效果:

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

<b>R       11.11.11.0 [120/1] via 192.168.1.1, 00:00:17, Serial0/0</b>

<b></b>

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

<b>R       3.3.3.3 [120/1] via 192.168.1.2, 00:00:07, Serial0/0</b>

<b>R       23.23.23.23 [120/2] via 192.168.1.2, 00:00:07, Serial0/0</b>

C       11.11.11.0 is directly connected, Loopback1

r1#

从上面可以看出R1学习到了3.3.3.0/24这条路由的路数为1,学习到23.23.23.0/24这条路由为2跳!!!实验配置成功!!!

拓扑图2:

在R1上先不要配置111.111.111.111这条,先配置好下面参数,等一下测试要用到。

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 //设置其它路由匹配(允许重发布)

 redistribute connected route-map connected  //在RIP重发布直连路由时应用上面配置的路由图connected

R2:与上个拓扑图配置一样。

O       3.3.3.3 [110/65] via 192.168.2.2, 00:25:40, Serial0/1

O       23.23.23.23 [110/65] via 192.168.2.2, 00:25:40, Serial0/1

<b>R       11.11.11.0 [120/1] via 192.168.1.1, 00:00:11, Serial0/0</b>

可以看出了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(config)#int l2

r1(config-if)#ip add 111.111.111.111 255.255.255.0

r1(config-if)#no sh

r1(config-if)#

O       3.3.3.3 [110/65] via 192.168.2.2, 00:29:29, Serial0/1

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

<b>R       111.111.111.0 [120/1] via 192.168.1.1, 00:00:18, Serial0/0</b>

R       11.11.11.0 [120/1] via 192.168.1.1, 00:00:18, Serial0/0

看到了吧,R2马上就学习到了!!!

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

继续阅读