2、区别不同区域的路由。
3、掌握OSPF 的路由汇总配置。
4、掌握OSPF 的基本配置命令。
路由器配置:
R1(config)#int Lo0
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)#intS0/0
R1(config-if)# ip address 192.168.1.1 255.255.255.252
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)# network 10.1.1.0 0.0.0.255 area 1
R1(config-router)# network 10.1.2.0 0.0.0.255 area 1
R1(config-router)# network 192.168.1.0 0.0.0.3 area 1
R1(config-router)#exit
R2(config)#int s0/0
R2(config-if)#ip add 192.168.1.2 255.255.255.252
R2(config-if)#no sh
R2(config-if)#int s0/1
R2(config-if)#ip add 192.168.1.5 255.255.255.252
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#router ospf 1
R2(config-router)#network 192.168.1.0 0.0.0.3 a 1
R2(config-router)#network 192.168.1.4 0.0.0.3 a 0
R2(config-router)#exit
R3(config)#int s0/0
R3(config-if)#ip add 192.168.1.6 255.255.255.252
R3(config-if)#no sh
R3(config-if)#int s0/1
R3(config-if)#ip add 192.168.1.9 255.255.255.252
R3(config-if)#no sh
R3(config-if)#exit
R3(config)#router ospf 1
R3(config-router)#network 192.168.1.4 0.0.0.3 a 0
R3(config-router)#network 192.168.1.8 0.0.0.3 a 2
R3(config-router)#exit
R4(config)#int s0/0
R4(config-if)#ip add 192.168.1.10 255.255.255.252
R4(config-if)#no sh
R4(config-if)#int lo0
R4(config-if)#ip add 172.16.1.1 255.255.255.0
R4(config-if)#int lo1
R4(config-if)#ip add 172.16.2.1 255.255.255.0
R4(config-if)#exit
R4(config)#router ospf 1
R4(config-router)#network 192.168.1.8 0.0.0.3 a 2
R4(config-router)#network 172.16.1.0 0.0.0.255 a 2
R4(config-router)#network 172.16.2.0 0.0.0.255 a 2
R4(config-router)#exit
在R2和R3上查看邻居表:
从这里可以看出所有的邻居关系都已经正常建立。
查看R1路由表:
R1#show ip route
Gateway of last resort is not set
172.16.0.0/32 is subnetted, 2 subnets
O IA 172.16.1.1 [110/193] via 192.168.1.2, 00:07:41, Serial0/0
O IA 172.16.2.1 [110/193] via 192.168.1.2, 00:07:31, Serial0/0
10.0.0.0/24 is subnetted, 2 subnets
C 10.1.2.0 is directly connected, Loopback1
C 10.1.1.0 is directly connected, Loopback0
192.168.1.0/30 is subnetted, 3 subnets
O IA 192.168.1.8 [110/192] via 192.168.1.2, 00:08:50, Serial0/0
C 192.168.1.0 is directly connected, Serial0/0
O IA 192.168.1.4 [110/128] via 192.168.1.2, 00:11:50, Serial0/0
其它区域的路由使用IA作为前缀,IA=>OSPF inter area。
前面一个数是OSPF的管理距离,后一个数是OSPF对于此链路计算的COST值,Cost = 10^8 / BW ,这里的BW不是指链路的物理带宽,可以通过bandwidth命令修改,Serial接口默认带宽为T1=1.54Mbps。
R1的链路状态数据库:
(1)类型1的LSA (2)类型3的LSA,描述区域间的路由
R1可以测通其它区域的网络:
R1#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/101/220 ms
在R4上:
R4#show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, Loopback0
C 172.16.2.0 is directly connected, Loopback1
10.0.0.0/32 is subnetted, 2 subnets
O IA 10.1.2.1 [110/193] via 192.168.1.9, 00:00:04, Serial0/0
O IA 10.1.1.1 [110/193] via 192.168.1.9, 00:00:04, Serial0/0
192.168.1.0/30 is subnetted, 3 subnets
C 192.168.1.8 is directly connected, Serial0/0
O IA 192.168.1.0 [110/192] via 192.168.1.9, 01:18:19, Serial0/0
O IA 192.168.1.4 [110/128] via 192.168.1.9, 01:18:19, Serial0/0
加粗条目分别是关于区域1的两条路由条目和类型3的LSA。
R4学习到的是具体条目,假如其它区域的信息很多,则路由表会很大,可以在R2(ABR)上对Area1的路由进行汇总,通过汇总可以有效地减少路由表的大小,限制LSA扩散。
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#router ospf 1
R2(config-router)#area 1 range 10.1.0.0 255.255.0.0
R2(config-router)#exit
再次查看R4的路由表和数据库:
R4#show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, Loopback0
C 172.16.2.0 is directly connected, Loopback1
10.0.0.0/16 is subnetted, 1 subnets
O IA 10.1.0.0 [110/193] via 192.168.1.9, 00:00:10, Serial0/0
192.168.1.0/30 is subnetted, 3 subnets
C 192.168.1.8 is directly connected, Serial0/0
O IA 192.168.1.0 [110/192] via 192.168.1.9, 01:19:36, Serial0/0
O IA 192.168.1.4 [110/128] via 192.168.1.9, 01:19:36, Serial0/0
加粗条目表明被成功汇总,这在跨地域有分部的大中型企业来说有很大好处,可以大大地缩减路由表,使跟帖条目更简洁,方便排错和管理,减少路由器查询路由表所花费的时间。
同样可以在R3上配置对172.16.0.0/16的汇总,在R1可以看到效果:
实验做完,搞定收功。