一、OSPF路由彙總優點:
OSPF路由彙總可以減少路由表條目,減少類型3和類型5的LSA的洪泛,節約帶寬資源和減輕路由器CPU負載,還能夠對拓撲的變化本地化。
二、OSPF路由彙總的兩種類型如下: (兩種方式均會示範)
1.inter-area(IA) route summarization:發生在ABR上
2.external route summarization:發生在ASBR上
三、實驗1:OSPF區域間彙總,發生在ABR上,接口資訊及IP位址規劃,區域資訊如拓撲所示。
步驟一:配置3台路由器,并且用OSPF。
R1:
R1>
R1>en
R1#conf t
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#interface loopback 0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#int lo1
R1(config-if)#ip address 10.1.2.1 255.255.255.0
R1(config-if)#int lo2
R1(config-if)#ip address 10.1.3.1 255.255.255.0
R1(config)#router ospf 1 //啟用OSPF路由協定
R1(config-router)#network 10.1.1.1 0.0.0.0 area 1 //釋出網段
R1(config-router)#network 10.1.2.1 0.0.0.0 area 1
R1(config-router)#network 10.1.3.1 0.0.0.0 area 1
R1(config-router)#network 192.168.1.1 0.0.0.0 area 1
R1(config-router)#end
R1#
R2:
R2>en
R2#conf t
R2(config)#interface f0/0
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-router)#exit
R2(config)#interface f0/1
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#router ospf 1 //啟用OSPF路由協定
R2(config-router)#network 192.168.1.2 0.0.0.0 area 1 //同上
R2(config-router)#network 192.168.2.2 0.0.0.0 area 0
R2(config-router)#end
R2#
R3:
R3>
R3>en
R3#conf t
R3(config)#interface f0/1
R3(config-if)#ip add
R3(config-if)#ip address 192.168.2.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#exit
R3(config)#router ospf 1 //同上
R3(config-router)#network 192.168.2.1 0.0.0.0 area 0
R3(config-router)#end
R3#
檢視R3路由表: //已經學習到R1三條明細路由
R3#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, 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, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/32 is subnetted, 3 subnets
O IA 10.1.1.1 [110/3] via 192.168.2.2, 00:01:18, FastEthernet0/1
O IA 10.1.2.1 [110/3] via 192.168.2.2, 00:01:18, FastEthernet0/1
O IA 10.1.3.1 [110/3] via 192.168.2.2, 00:01:18, FastEthernet0/1
O IA 192.168.1.0/24 [110/2] via 192.168.2.2, 00:01:18, FastEthernet0/1
C 192.168.2.0/24 is directly connected, FastEthernet0/1
步驟二:在R2(ABR)上執行彙總,再次檢視R3上路由表
R2(config)#router ospf 1
R2(config-router)#area 1 range 10.1.0.0 255.255.252.0
//把3條明細路由彙總為掩碼為/22的彙總路由.
檢視R3路由表:
10.0.0.0/22 is subnetted, 1 subnets
O IA 10.1.0.0 [110/65] via 192.168.2.2, 00:00:16, FastEthernet0/1
//變為掩碼為22的彙總路由
實驗2:OSPF域間彙總,發生在(ASBR)上,拓撲如下,R1運作了OSPF與RIP兩種路由協定,是以它為ASBR,IP位址與區域已規劃好.
步驟一:在2台路由器上配置OSPF與RIP,并釋出網段.
Router>
Router>en
Router#conf t
Router(config)#hostname R1
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config)#interface loopback 0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#int lo1
R1(config-if)#ip address 10.1.2.1 255.255.255.0
R1(config-if)#int lo2
R1(config-if)#ip address 10.1.3.1 255.255.255.0
R1(config)#router ospf 1 //啟用OSPF路由協定
R1(config-router)#network 192.168.1.1 0.0.0.0 area 0
R1(config-router)#exit
R1(config)#router rip //啟用RIP路由協定
R1(config-router)#version 2 //指定版本2
R1(config-router)#no auto-summary //不要自動彙總
R1(config-router)#network 10.1.1.0 //釋出網段
R1(config-router)#network 10.1.2.0
R1(config-router)#network 10.1.3.0
R1(config)#end
R2:
Router(config)#hostname R2
R2(config)#interface f0/0
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no sh
R2(config)#router ospf 1 //同上
R2(config-router)#network 192.168.1.2 0.0.0.0 area 0
步驟二:在R1上把RIP與OSPF互相重釋出,并檢視R2路由表.
R1(config)#router rip
R1(config-router)#redistribute ospf 1 metric 1 //把OSPF釋出進RIP,路徑成本為1
R1(config)#router ospf 1
R1(config-router)#redistribute rip subnets //把RIP路由釋出進OSPF
檢視R2路由表: //此時已經學習重釋出進OSPF的外部路由表條目
R2#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, 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, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 3 subnets
O E2 10.1.3.0 [110/20] via 192.168.1.1, 00:00:40, FastEthernet0/0
O E2 10.1.2.0 [110/20] via 192.168.1.1, 00:00:40, FastEthernet0/0
O E2 10.1.1.0 [110/20] via 192.168.1.1, 00:00:40, FastEthernet0/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
注:E2表示OSPF的外部路由類型2.
步驟三:在R1(ASBR)上做域間彙總,使得3條明細彙總為一條.并檢視R2路由表.
R1(config-router)#summary-address 10.1.0.0 255.255.252.0
//把之前3條明細路由彙總成掩碼為22的彙總路由
檢視R2路由表:
R2#show ip route //此時已經變為掩碼為22的彙總路由.
10.0.0.0/22 is subnetted, 1 subnets
O E2 10.1.0.0 [110/20] via 192.168.1.1, 00:00:44, FastEthernet0/0
實驗完成.
本文轉自 meiyanaa 51CTO部落格,原文連結:http://blog.51cto.com/justim/270551,如需轉載請自行聯系原作者