2、掌握OSPF 虚链路配置方法
配置好各设备IP地址信息,和基本的动态路由协议信息,测试好互连地址可达。
先配置R2、R3、R4的OSPF协议,在R2上先不要配置network s0/0网络。
查看R2路由表:
R2#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
C 172.16.255.0/30 is directly connected, Serial0/0
C 172.16.255.4/30 is directly connected, Serial0/1
O IA 172.16.255.8/30 [110/128] via 172.16.255.6, 00:01:46, Serial0/1
O IA 172.16.16.1/32 [110/129] via 172.16.255.6, 00:00:54, Serial0/1
再配置R1和R2的OSPF协议:
R1(config)#router ospf 1
R1(config-router)#network 172.16.1.0 0.0.0.255 a 3
R1(config-router)#network 172.16.255.0 0.0.0.3 a 3
R1(config-router)#exit
R2(config)#router ospf 1
R2(config-router)#network 172.16.255.0 0.0.0.3 a 3
R2(config-router)#exit
查看R1与R2的邻居表:
正常建立邻居。
查看R1路由表:
R1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.255.0/30 is directly connected, Serial0/0
C 172.16.1.0/24 is directly connected, Loopback0
观察发现R1没有学习到骨干区域、Area 1、Area 2的路由,造成这个问题的主要原因是:area 3 区域与骨干区域area 0 被分割。OSPF 的区域配置规则是:普通区域必须与骨干区域直连。
当有这种问题出现时,可以使用虚链路的配置方案解决。使用虚链路可以确保非直连区域能够逻辑认为自己与骨干区域直连。
可在R2和R3上按如下配置:
R2(config)#router ospf 1
R2(config-router)#area 2 virtual-link 172.16.255.9--------------->创建一条虚链路
R2(config-router)#exit
命令中area 2指出这条虚链路存在于area 2中,virtual-link 172.16.255.9指出对端R3路由器的router-id。
R3(config)#router ospf 1
R3(config-router)#area 2 virtual-link 172.16.255.5
R3(config-router)#exit
配置到R2虚链路,使用的是router-id,而不是接口IP地址。
查看R2的邻居表:
查看R1的路由表:
R1#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 5 subnets, 3 masks
C 172.16.255.0/30 is directly connected, Serial0/0
O IA 172.16.255.4/30 [110/128] via 172.16.255.2, 00:10:15, Serial0/0
O IA 172.16.255.8/30 [110/192] via 172.16.255.2, 00:08:44, Serial0/0
O IA 172.16.16.1/32 [110/193] via 172.16.255.2, 00:08:44, Serial0/0
C 172.16.1.0/24 is directly connected, Loopback0
R1已经学习到其它区域的路由信息。
测试连通性:
R1#ping 172.16.16.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.16.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/71/96 ms
一切正常。