在OSPF 网络中,区域0为骨干区域,其它的为非骨干区域,非骨干区域必须与骨干区域直接相连。
根据拓扑图可看到区域1与骨干区域0直接相连而区域2与骨干区域没有直接相连,这种情况下我们可以创建一条虚链路使区域2与骨干区域0直接相连。虚链路还可将不连续的区域0连接起来。
R1配置:
interface Loopback1
ip address 1.1.1.1 255.255.255.255
!
interface Serial1/1
ip address 12.12.12.1 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 12.12.12.0 0.0.0.255 area 0
!
R2配置:
interface Loopback1
ip address 2.2.2.2 255.255.255.0
!
interface Serial1/0
ip address 12.12.12.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 23.23.23.2 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
area 1 virtual-link 4.4.4.4
network 2.2.2.0 0.0.0.255 area 0
network 12.12.12.0 0.0.0.255 area 0
network 23.23.23.0 0.0.0.255 area 1
!
R3配置:
interface Loopback1
ip address 3.3.3.3 255.255.255.255
!
interface Serial1/0
ip address 23.23.23.3 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 34.34.34.3 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 3.3.3.3
log-adjacency-changes
network 3.3.3.0 0.0.0.255 area 1
network 23.23.23.0 0.0.0.255 area 1
network 34.34.34.0 0.0.0.255 area 1
!
R4配置:
interface Loopback1
ip address 4.4.4.4 255.255.255.0
!
interface Serial1/0
ip address 34.34.34.4 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 45.45.45.4 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 4.4.4.4
log-adjacency-changes
area 1 virtual-link 2.2.2.2
network 4.4.4.0 0.0.0.255 area 1
network 34.34.34.0 0.0.0.255 area 1
network 45.45.45.0 0.0.0.255 area 2
!
R5配置:
interface Loopback1
ip address 5.5.5.5 255.255.255.0
!
interface Serial1/0
ip address 45.45.45.5 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 5.5.5.5
log-adjacency-changes
network 5.5.5.0 0.0.0.255 area 2
network 45.45.45.0 0.0.0.255 area 2
!
配置虚链路后再次查看R1的路由表,已经学到了区域2的路由:
Router(config-router)#do show ip route
Codes: C - connected, S - static, 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
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
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.34.34.0 [110/192] via 12.12.12.2, 00:08:26, Serial1/1
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.12.12.2, 00:08:26, Serial1/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.12.12.2, 00:08:26, Serial1/1
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/193] via 12.12.12.2, 00:08:26, Serial1/1
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/257] via 12.12.12.2, 00:08:26, Serial1/1 //区域2路由
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.23.23.0 [110/128] via 12.12.12.2, 00:08:27, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, Serial1/1
45.0.0.0/24 is subnetted, 1 subnets
O IA 45.45.45.0 [110/256] via 12.12.12.2, 00:08:27, Serial1/1 //区域2路由
在末配置虚链路时查看R1的路由表,R1是学不到区域2的路由
Router#show ip route
Codes: C - connected, S - static, 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
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
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.34.34.0 [110/192] via 12.12.12.2, 00:12:49, Serial1/1
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.12.12.2, 00:12:49, Serial1/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.12.12.2, 00:12:49, Serial1/1
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/193] via 12.12.12.2, 00:12:49, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.23.23.0 [110/128] via 12.12.12.2, 00:12:49, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, Serial1/1