路由图重分布OSPFRIP的例子
如上例图所示:“RIP与OSPF路由重分布例子”
switchA(config)#router rip
switchA(config-router)#network 192.168.10.0
switchA(config-router)#network 192.168.20.0
switchA(config-router)#network 192.168.1.0
switchA(config-router)#version 2
switchA(config-router)#no auto-summary
switchA(config-router)#exit
switchA(config)#end
router(config)#router rip
router(config-router)#network 192.168.1.0
router(config-router)#network 192.168.2.0
router(config-router)#redistribute ospf metric 3//设置路由重分布,rip重分布到ospf
router(config-router)#version 2
router(config-router)#no auto-summary
router(config-router)#exit
router(config)#router ospf
router(config-router)#network 192.168.1.0 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />0.0.0.255 area 0
router(config-router)#network 192.168.2.0 0.0.0.255 area 0
router(config-router)#redistriblute rip subnets//设置路由重分布,ospf重分布到rip
router(config-router)#exit
router(config)#end
以上是配置重分布是没有任何要求的例子,下面使用路由图来进行重分布的配置:
Router(config)#access-list 10 permit 192.168.10.0 0.0.0.255
Router(config)#route-map rmap permit 10
Router(config-route-map)#match ip address 10
Router(config-route-map)#exit
Router(config)#router rip
Router(config-router)#redistribute ospf  route-map rmap metric 3//设置路由重分布,rip重分布到ospf,采用路由图进行重分布配置
配置后再查看三台设备路由表的情况:
Router:
Router#show ip route<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

Codes:  C - connected, S - static,  R - RIP B - BGP

        O - OSPF, IA - OSPF inter area

        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

        E1 - OSPF external type 1, E2 - OSPF external type 2

        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

 

        * - candidate default

 

Gateway of last resort is no set

C    192.168.1.0/24 is directly connected, FastEthernet 0/0

C    192.168.1.2/32 is local host.

C    192.168.2.0/24 is directly connected, FastEthernet 0/1

C    192.168.2.2/32 is local host.

R    192.168.10.0/24 [120/1] via 192.168.1.1, 00:00:07, FastEthernet 0/0

R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:07, FastEthernet 0/0

O    192.168.30.0/24 [110/2] via 192.168.2.1, 00:19:36, FastEthernet 0/1

O    192.168.40.0/24 [110/2] via 192.168.2.1, 00:20:45, FastEthernet 0/1

 

switchA:
switchA#show ip route

 

Codes:  C - connected, S - static,  R - RIP B - BGP

        O - OSPF, IA - OSPF inter area

        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

        E1 - OSPF external type 1, E2 - OSPF external type 2

        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

 

        * - candidate default

 

Gateway of last resort is no set

C    192.168.1.0/24 is directly connected, FastEthernet 0/1

C    192.168.1.1/32 is local host.

C    192.168.10.0/24 is directly connected, VLAN 10

C    192.168.10.1/32 is local host.

C    192.168.20.0/24 is directly connected, VLAN 20

C    192.168.20.1/32 is local host.

R    192.168.30.0/24 [120/3] via 192.168.1.2, 00:00:21, FastEthernet 0/1

R    192.168.40.0/24 [120/3] via 192.168.1.2, 00:00:21, FastEthernet 0/1
R    192.168.2.0/24 [120/3] via 192.168.1.2, 00:00:21, FastEthernet 0/1

 

switchB:
switchB#show ip route

 

Codes:  C - connected, S - static,  R - RIP B - BGP

        O - OSPF, IA - OSPF inter area

        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

        E1 - OSPF external type 1, E2 - OSPF external type 2

        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

 

        * - candidate default

 

Gateway of last resort is no set

C    192.168.2.0/24 is directly connected, FastEthernet 0/1

C    192.168.2.1/32 is local host.

O E2 192.168.10.0/24 [110/20] via 192.168.2.2, 00:22:48, FastEthernet 0/1
C    192.168.30.0/24 is directly connected, VLAN 10

C    192.168.30.1/32 is local host.

C    192.168.40.0/24 is directly connected, VLAN 20

C    192.168.40.1/32 is local host.
根据以上路由表的分析, switchB 只学到了 switchA 一条 192.168.10.0 的一条路由,而其他的路由没有公布出来,起到了控制的作用。利用路由图的重分布的例子,比较灵活,不光可以匹配列表,还可匹配不同的路由协议的参数,进行控制,但是也有很多问题,希望用户慎重使用,路由图的使用不光是针对重分布使用时应用,还可以基于高层的策略路由的应用,下个例子会讲到!谢谢大家支持!请大家多多指教。