OSPF与静态路由分布配置
如上例图所示:“RIP与OSPF路由重分布例子”
switchA(config)#router ospf
switchA(config-router)#network 192.168.10.0 0.0.0.255 area 0
switchA(config-router)#network 192.168.20.0 0.0.0.255 area 0
switchA(config-router)#network 192.168.1.0 0.0.0.255 area 0
switchA(config-router)#exit
switchA(config)#end
router(config)#router ospf
router(config-router)#network 192.168.1.0 0.0.0.255 area 0
router(config-router)#network 192.168.2.0 0.0.0.255 area 0
router(config-router)#exit
router(config)#ip route 192.168.30.0 255.255.255.0 192.168.2.1
router(config)#ip route 192.168.40.0 255.255.255.0 192.168.2.1
router(config)#end
switchB(config)#ip route 192.168.10.0 255.255.255.0 192.168.2.2
switchB(config)#ip route 192.168.20.0 255.255.255.0 192.168.2.2
switchB(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
switchB(config)#end
在互连路由器上进行重分布配置,使其两个不同路由协议的网络进行互通
Router(config)#router ospf
Router(config-router)#redistribute static subnets//将OSPF重分布到静态路由
Router(config-router)#exit
Router(config)#end
此例我只是做了把OSPF重分布到静态路由,是因为静态路由本身就是一个明确的邻接路由,因为我们在switchB上已经明确指定静态路由了,所以就没有做相关的重分布配置,话说过来,网络设备也没有提供相就的静态路由重分布的方法。
配置好后:三台设备的路由表情况如下:
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.
O 192.168.10.0/24 [110/2] via 192.168.1.2, 1d,22:44:08, FastEthernet 0/0
O 192.168.20.0/24 [110/2] via 192.168.1.2, 1d,22:44:08, FastEthernet 0/0
S 192.168.30.0/24 [1/0] via 192.168.2.1
S 192.168.40.0/24 [1/0] via 192.168.2.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.
O 192.168.30.0/24 [110/2] via 192.168.1.2, 1d,22:44:08, FastEthernet 0/0
O 192.168.40.0/24 [110/2] via 192.168.1.2, 1d,22:44:08, FastEthernet 0/0
O 192.168.2.0/24 [110/2] via 192.168.1.2, 1d,22:44:08, 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.
S 192.168.10.0/24 [1/0] via 192.168.2.2
S 192.168.20.0/24 [1/0] via 192.168.2.2
S 192.168.1.0/24 [1/0] via 192.168.2.2
C 192.168.40.0/24 is directly connected, VLAN 20
C 192.168.40.1/32 is local host.
根据上述的路由表的分析我们得知
OSPF
与
static
的路由重分布成功。