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:
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:15, FastEthernet 0/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:15, FastEthernet 0/0
O    192.168.30.0/24 [110/2] via 192.168.2.1, 1d,22:44:08, FastEthernet 0/1
O    192.168.40.0/24 [110/2] via 192.168.2.1, 1d,22:44:08, 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/1] via 192.168.1.2, 00:00:15, FastEthernet 0/0
R    192.168.40.0/24 [120/1] via 192.168.1.2, 00:00:15, FastEthernet 0/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:15, FastEthernet 0/0

 

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, 1d,22:42:49, FastEthernet 0/1
O E2 192.168.20.0/24 [110/20] via 192.168.2.2, 1d,22:42:49, FastEthernet 0/1
O E2 192.168.1.0/24 [110/20] via 192.168.2.2, 1d,22:42:49, FastEthernet 0/1
C    192.168.40.0/24 is directly connected, VLAN 20
C    192.168.40.1/32 is local host.
根据上述的路由表的分析我们得知ripOSPF的路由重分布成功。
可以得知,当没有配置重分布列表时,用户是无法控制路由重分布路由的条数下面让我们来配置重分布列表,看一下有什么变化:
Router(config)#access-list 10 permit 192.168.10.0 0.0.0.255
Router(config)#router rip
Router(config)#distribute-list 10 out ospf //配置重分布任务列表10当中的允许匹配源路由的路由重分布到OSPF当中。
这时再观察三台设备的路由表情况:
Router:
Router#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/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:15, FastEthernet 0/0
R    192.168.20.0/24 [120/1] via 192.168.1.1, 00:00:15, FastEthernet 0/0
O    192.168.30.0/24 [110/2] via 192.168.2.1, 1d,22:44:08, FastEthernet 0/1
O    192.168.40.0/24 [110/2] via 192.168.2.1, 1d,22:44:08, 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/1] via 192.168.1.2, 00:00:15, FastEthernet 0/0
R    192.168.40.0/24 [120/1] via 192.168.1.2, 00:00:15, FastEthernet 0/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:15, FastEthernet 0/0

 

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, 1d,22:42:49, FastEthernet 0/1
O E2 192.168.1.0/24 [110/20] via 192.168.2.2, 1d,22:42:49, FastEthernet 0/1
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 这条路由,而没有 switchA 的其他路由,这就控制路由的通告控制。