一、OSPF的工作原理

OSPF(开放最短路径优先)是一种分层次的路由协议,其层次中最大的实体是AS(自治系统),即遵循共同路由策略管理下的一部分网络实体。在每个AS中,将网络划分为不同的区域。每个区域都有自己特定的标识号。对于主干(backbone)区域,负责在区域之间分发链路状态信息这种分层的网络结构是根据OSPF的实际提出来的。当网络中自治系统非常大时,网络拓扑数据库的内容就更多,所以如果不分层次的话,一方面容易造成数据库溢出,另一方面当网络中某一链路状态发生改变时,会引起整个网络中每个节点都重新计算一边自己的路由表,既浪费资源与时间又会影响路由协议的性能,因此,需要把自治系统划分为多个域,每个域内部路由总结后在域间扩散。这样,当网络中的某条链路状态发生改变时此链路所在的域中的每个路由器重新计算本域路由表,而其它域中的路由器只需修改其路由表中的相应条目而无须重新计算整个路由表,节省了计算路由表的时间。


二、OSPF的特性
1、OSPF采用触发更新方式更新路由,节省带宽;
2、更新消息采用组播形式发送,组播地址:224.0.0.5  224.0.0.6
3、metric cost(根据带宽计算的)。
4、无规模限制;
5、收敛速度快;
6、路径是无环的;
7、只能做等代价负载均衡;
8、具有三张表格:(1)、邻居表格(Hello包),互换信息;
                        (2)、链路状态数据库(LSDB)
                        (3)、SPF---算出路由表    
9、支持子网不连续; 

三、案例1

拓扑图

wps_clip_image-32302

 

配置步骤

1、给各路由器配置ip地址

(1)、给R1各接口配置ip地址:

R1(config)#int s0/0

R1(config-if)#ip add 192.168.1.1 255.255.255.0

R1(config-if)#no shut

R1(config-if)#int s0/1

R1(config-if)#ip add 192.168.3.1 255.255.255.0

R1(config-if)#no shut

R1(config-if)#int s0/2

R1(config-if)#ip add 192.168.4.1 255.255.255.0

R1(config-if)#no shut

(2)、给R1各接口配置ip地址:

R2(config)#int s0/1

R2(config-if)#ip add 192.168.3.2 255.255.255.0

R2(config-if)#no shut

R2(config-if)#int f1/0

R2(config-if)#ip add 192.168.7.1 255.255.255.0

R2(config-if)#no shut

R2(config-if)#loopback

(3)、给R3各接口配置ip地址:

R3(config)#int s0/0

R3(config-if)#ip add 192.168.1.2 255.255.255.0

R3(config-if)#no shut

R3(config-if)#int s0/1

R3(config-if)#ip add 192.168.2.1 255.255.255.0

R3(config-if)#no shut

(4)、给R4各接口配置ip地址:

R4(config)#int s0/1

R4(config-if)#ip add 192.168.2.2 255.255.255.0

R4(config-if)#no shut

R4(config-if)#int f1/0

R4(config-if)#ip add 192.168.6.1 255.255.255.0

R4(config-if)#no shut

R4(config-if)#loopback

(5)、给R5各接口配置ip地址:

R5(config)#int s0/2

R5(config-if)#ip add 192.168.4.2 255.255.255.0

R5(config-if)#no shut

R5(config-if)#int s0/0

R5(config-if)#ip add 192.168.5.1 255.255.255.0

R5(config-if)#no shut

(6)、给R6各接口配置ip地址:

R6(config)#int s0/0

R6(config-if)#ip add 192.168.5.2 255.255.255.0

R6(config-if)#no shut

R6(config-if)#int f1/0

R6(config-if)#ip add 192.168.8.1 255.255.255.0

R6(config-if)#no shut

R6(config-if)#loopback

R6(config-if)#end

2、给个路由器配置相应路由协议

(1)、在R1上启动OSPF协议和RIP协议

R1(config)#router ospf 112

R1(config-router)#net 192.168.1.0 0.0.0.255 area 0

R1(config-router)#net 192.168.3.0 0.0.0.255 area 1

R1(config-router)#exit

R1(config)#router rip

R1(config-router)#net 192.168.4.0

R1(config-router)#end

(2)、在R2上启动OSPF协议

R2(config)#router ospf 112

R2(config-router)#net 192.168.3.0 0.0.0.255 area 1

R2(config-router)#net 192.168.7.0 0.0.0.255 area 1

R2(config-router)#end

(3)、在R3上启动OSPF协议

R3(config)#router ospf 112

R3(config-router)#net 192.168.1.0 0.0.0.255 area 0

R3(config-router)#net 192.168.2.0 0.0.0.255 area 2

(4)、在R4上启动OSPF协议

R4(config)#router ospf 112

R4(config-router)#net 192.168.2.0 0.0.0.255 area 0

R4(config-router)#net 192.168.6.0 0.0.0.255 area 2

(5)、在R5上启动RIP协议

R5(config)#router rip

R5(config-router)#net 192.168.4.0

R5(config-router)#net 192.168.5.0

(6)、在R6上启动RIP协议

R6(config)#router rip

R6(config-router)#net 192.168.5.0

R6(config-router)#net 192.168.8.0

3、查看各路由表信息

R1#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

R    192.168.8.0/24 [120/2] via 192.168.4.2, 00:00:08, Serial0/2

C    192.168.4.0/24 is directly connected, Serial0/2

R    192.168.5.0/24 [120/1] via 192.168.4.2, 00:00:08, Serial0/2

O IA 192.168.6.0/24 [110/129] via 192.168.1.2, 00:02:55, Serial0/0

O    192.168.7.0/24 [110/65] via 192.168.3.2, 00:06:08, Serial0/1

C    192.168.1.0/24 is directly connected, Serial0/0

O IA 192.168.2.0/24 [110/128] via 192.168.1.2, 00:04:20, Serial0/0

C    192.168.3.0/24 is directly connected, Serial0/1

在R3中启动OSPF协议和RIP协议后,其路由表中出现三条关于OSPF协议路由,两条关于RIP协议的路由

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

O IA 192.168.6.0/24 [110/193] via 192.168.3.1, 00:03:16, Serial0/1

C    192.168.7.0/24 is directly connected, FastEthernet1/0

O IA 192.168.1.0/24 [110/128] via 192.168.3.1, 00:06:30, Serial0/1

O IA 192.168.2.0/24 [110/192] via 192.168.3.1, 00:04:41, Serial0/1

C    192.168.3.0/24 is directly connected, Serial0/1

在R3中启动OSPF协议后,其路由表中出现三条关于OSPF协议路由

R3#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

O    192.168.6.0/24 [110/65] via 192.168.2.2, 00:02:04, Serial0/1

O IA 192.168.7.0/24 [110/129] via 192.168.1.1, 00:01:43, Serial0/0

C    192.168.1.0/24 is directly connected, Serial0/0

C    192.168.2.0/24 is directly connected, Serial0/1

O IA 192.168.3.0/24 [110/128] via 192.168.1.1, 00:01:43, Serial0/0

在R3中启动OSPF协议后,其路由表中出现三条关于OSPF协议路由

R4#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

C    192.168.6.0/24 is directly connected, FastEthernet1/0

O IA 192.168.7.0/24 [110/193] via 192.168.2.1, 00:03:49, Serial0/1

O IA 192.168.1.0/24 [110/128] via 192.168.2.1, 00:03:49, Serial0/1

C    192.168.2.0/24 is directly connected, Serial0/1

O IA 192.168.3.0/24 [110/192] via 192.168.2.1, 00:03:49, Serial0/1

在R4中启动OSPF协议后,其路由表中出现三条关于OSPF协议路由

R5#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

R    192.168.8.0/24 [120/1] via 192.168.5.2, 00:00:02, Serial0/0

C    192.168.4.0/24 is directly connected, Serial0/2

C    192.168.5.0/24 is directly connected, Serial0/0

在R5中启动RIP协议后,其路由表中出现一条关于RIP协议路由

R6#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

C    192.168.8.0/24 is directly connected, FastEthernet1/0

R    192.168.4.0/24 [120/1] via 192.168.5.1, 00:00:15, Serial0/0

C    192.168.5.0/24 is directly connected, Serial0/0

在R6中启动RIP协议后,其路由表中出现一条关于RIP协议路由

4、在R1中启动OSPF 协议并再分发RIP协议使R2,R3,R4能学到R5,R6的路由表信息;然后再在R1中启动RIP协议并添加一条默认认路由使R5,R6能学到R1,R2,R3,R4的路由表信息。

R1(config)#router ospf 112

R1(config-router)#redistribute rip metric 100 subnets

R1(config)#router rip

R1(config-router)#default-information originate

查看各路由表信息

R1#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

R    192.168.8.0/24 [120/2] via 192.168.4.2, 00:00:23, Serial0/2

C    192.168.4.0/24 is directly connected, Serial0/2

R    192.168.5.0/24 [120/1] via 192.168.4.2, 00:00:23, Serial0/2

O IA 192.168.6.0/24 [110/129] via 192.168.1.2, 00:00:29, Serial0/0

O    192.168.7.0/24 [110/65] via 192.168.3.2, 00:00:29, Serial0/1

C    192.168.1.0/24 is directly connected, Serial0/0

O IA 192.168.2.0/24 [110/128] via 192.168.1.2, 00:00:29, Serial0/0

C    192.168.3.0/24 is directly connected, Serial0/1

R2#clear ip route *

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

O E2 192.168.8.0/24 [110/100] via 192.168.3.1, 00:00:03, Serial0/1

O E2 192.168.4.0/24 [110/100] via 192.168.3.1, 00:00:03, Serial0/1

O E2 192.168.5.0/24 [110/100] via 192.168.3.1, 00:00:03, Serial0/1

O IA 192.168.6.0/24 [110/193] via 192.168.3.1, 00:00:03, Serial0/1

C    192.168.7.0/24 is directly connected, FastEthernet1/0

O IA 192.168.1.0/24 [110/128] via 192.168.3.1, 00:00:03, Serial0/1

O IA 192.168.2.0/24 [110/192] via 192.168.3.1, 00:00:03, Serial0/1

C    192.168.3.0/24 is directly connected, Serial0/1

在R1中启动OSPF协议并再分发RIP协议后R2路由表中学到了R5,R6的路由信息

R3#clear ip route *

R3#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

O E2 192.168.8.0/24 [110/100] via 192.168.1.1, 00:00:07, Serial0/0

O E2 192.168.4.0/24 [110/100] via 192.168.1.1, 00:00:07, Serial0/0

O E2 192.168.5.0/24 [110/100] via 192.168.1.1, 00:00:07, Serial0/0

O    192.168.6.0/24 [110/65] via 192.168.2.2, 00:00:07, Serial0/1

O IA 192.168.7.0/24 [110/129] via 192.168.1.1, 00:00:07, Serial0/0

C    192.168.1.0/24 is directly connected, Serial0/0

C    192.168.2.0/24 is directly connected, Serial0/1

O IA 192.168.3.0/24 [110/128] via 192.168.1.1, 00:00:07, Serial0/0

在R1中启动OSPF协议并再分发RIP协议后R3路由表中学到了R5,R6的路由信息

R4#clear ip route *

R4#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

O E2 192.168.8.0/24 [110/100] via 192.168.2.1, 00:00:02, Serial0/1

O E2 192.168.4.0/24 [110/100] via 192.168.2.1, 00:00:02, Serial0/1

O E2 192.168.5.0/24 [110/100] via 192.168.2.1, 00:00:02, Serial0/1

C    192.168.6.0/24 is directly connected, FastEthernet1/0

O IA 192.168.7.0/24 [110/193] via 192.168.2.1, 00:00:02, Serial0/1

O IA 192.168.1.0/24 [110/128] via 192.168.2.1, 00:00:02, Serial0/1

C    192.168.2.0/24 is directly connected, Serial0/1

O IA 192.168.3.0/24 [110/192] via 192.168.2.1, 00:00:02, Serial0/1

在R1中启动OSPF协议并再分发RIP协议后R4路由表中学到了R5,R6的路由信息

R5#clear ip route *

R5#clear ip route *

R5#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 192.168.4.1 to network 0.0.0.0

R    192.168.8.0/24 [120/1] via 192.168.5.2, 00:00:02, Serial0/0

C    192.168.4.0/24 is directly connected, Serial0/2

C    192.168.5.0/24 is directly connected, Serial0/0

R*   0.0.0.0/0 [120/1] via 192.168.4.1, 00:00:02, Serial0/2

在R1中启动RIP协议并添加默认路由后R5路由表中出现一条默认路由

R6#clear ip route *

R6#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 192.168.5.1 to network 0.0.0.0

C    192.168.8.0/24 is directly connected, FastEthernet1/0

R    192.168.4.0/24 [120/1] via 192.168.5.1, 00:00:05, Serial0/0

C    192.168.5.0/24 is directly connected, Serial0/0

R*   0.0.0.0/0 [120/2] via 192.168.5.1, 00:00:05, Serial0/0

在R1中启动RIP协议并添加默认路由后R5路由表中出现一条默认路由

测试结果:

(1)、在R2上ping个路由器接口

R2#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/35/48 ms

R2#ping 192.168.8.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.8.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 84/106/144 ms

R2#ping 192.168.6.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 76/91/108 ms

R2#ping 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/36/76 ms

R2#ping 192.168.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 56/81/128 ms

R2#ping 192.168.2.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/54/72 ms

R2#ping 192.168.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 76/99/120 ms

R2#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/25/36 ms

R2#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 32/57/80 ms

R2#ping 192.168.4.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/28/60 ms

R2#ping 192.168.4.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/58/68 ms

R2#ping 192.168.5.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/61/96 ms

R2#ping 192.168.5.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 60/92/132 ms

R2与各个接口都能ping通

(2)、在R3上ping个路由器接口

R3#ping 192.168.8.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.8.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 68/94/128 ms

R3#ping 192.168.7.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.7.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 32/52/64 ms

R3#ping 192.168.6.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 32/39/64 ms

R3#ping 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/32/48 ms

R3#ping 192.168.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!.!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 72/87/112 ms

R3#ping 192.168.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/64/100 ms

R3#ping 192.168.2.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 64/71/80 ms

R3#ping 192.168.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 32/42/68 ms

R3#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 36/51/64 ms

R3#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/67/84 ms

R3#ping 192.168.4.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/40/68 ms

R3#ping 192.168.4.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 60/66/80 ms

R3#ping 192.168.5.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 32/64/92 ms

R3#ping 192.168.5.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/80/100 ms

R3与各个接口都能ping通

(3)、在R4上ping个路由器接口

R4#ping 192.168.8.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.8.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 96/119/156 ms

R4#ping 192.168.6.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

R4#ping 192.168.7.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.7.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 64/88/112 ms

R4#ping 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/60/92 ms

R4#ping 192.168.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/40/60 ms

R4#ping 192.168.2.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/32/44 ms

R4#ping 192.168.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/61/72 ms

R4#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/68/92 ms

R4#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 60/84/128 ms

R4#ping 192.168.4.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/53/76 ms

R4#ping 192.168.4.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 96/116/136 ms

R4#ping 192.168.5.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 100/136/172 ms

R4#ping 192.168.5.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 120/145/184 ms

R4与各个接口都能ping通

(4)、在R5上ping个路由器接口

R5#ping 192.168.7.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.7.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/51/76 ms

R5#ping 192.168.6.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 68/92/120 ms

R5#ping 192.168.8.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.8.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/32/48 ms

R5#ping 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/33/48 ms

R5#ping 192.168.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 52/91/156 ms

R5#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/35/80 ms

R5#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/62/92 ms

R5#ping 192.168.4.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 40/61/84 ms

R5#ping 192.168.5.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 60/64/68 ms

R5与各个接口都能ping通

(5)、在R6上ping个路由器接口

R6#ping 192.168.6.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 112/138/200 ms

R6#ping 192.168.7.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.7.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 60/91/128 ms

R6#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 56/93/160 ms

R6#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/60/80 ms

R6#ping 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/60/76 ms

R6#ping 192.168.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 64/101/148 ms

R6#ping 192.168.2.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 60/69/80 ms

R6#ping 192.168.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 112/149/208 ms

R6#ping 192.168.4.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 36/66/132 ms

R6#ping 192.168.4.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.4.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/35/60 ms

R6#ping 192.168.5.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/41/84 ms

R6#ping 192.168.5.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.5.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/66/108 ms

R6与各个接口都能ping通

各路由器与各个接口均能ping通

4、在R3和R4上将area2设置为末节区域,减少R4路由条目

R3(config)#router ospf 112

R3(config-router)#area 2 stub

R4(config)#router ospf 112

R4(config-router)#area 2 stub

查看R4路由表

R4#clear ip route *

R4#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 192.168.2.1 to network 0.0.0.0

C    192.168.6.0/24 is directly connected, FastEthernet1/0

O IA 192.168.7.0/24 [110/193] via 192.168.2.1, 00:00:09, Serial0/1

O IA 192.168.1.0/24 [110/128] via 192.168.2.1, 00:00:09, Serial0/1

C    192.168.2.0/24 is directly connected, Serial0/1

O IA 192.168.3.0/24 [110/192] via 192.168.2.1, 00:00:09, Serial0/1

O*IA 0.0.0.0/0 [110/65] via 192.168.2.1, 00:00:09, Serial0/1

在R3,R4上将area2设置为末节区域后,R4路由条目减少,R4中原来学到R5,R6路由信息没有了

5、在R3上将area2设置为完全末节区域,再次减少R4路由表条目

R3(config)#router ospf 112

R3(config-router)#area 2 stub no-summary

查看R4路由表

R4#clear ip route *

R4#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 192.168.2.1 to network 0.0.0.0

C    192.168.6.0/24 is directly connected, FastEthernet1/0

C    192.168.2.0/24 is directly connected, Serial0/1

O*IA 0.0.0.0/0 [110/65] via 192.168.2.1, 00:00:09, Serial0/

在R3上将area2设置为完全末节区域后,R4路由条目再次减少,与R4邻接的路由条目均减少了

测试结果:

再次在R4上ping各路由器接口:

R4#ping 192.168.8.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.8.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 324/350/400 ms

R4#ping 192.168.7.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.7.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 200/256/320 ms

R4#ping 192.168.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 120/145/160 ms

R4#ping 192.168.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 40/84/184 ms

R4#ping 192.168.2.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/115/168 ms

R4#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 108/206/260 ms

R4#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 156/200/228 ms

R4#ping 192.168.6.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:

!!!!!

将area2设置为完全末节区域后,虽然R4中路由条目只剩直连和一条默认路由了,但与各个接口依然能ping通