天天看點

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,如需轉載請自行聯系原作者

繼續閱讀