OSPF虚链路配置.示例1

时间:2022-08-09 21:09:21
OSPF虚链路配置.示例1
 

在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#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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-, L2 - IS-IS level-
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/ is subnetted, subnets
O IA 34.34.34.0 [/] via 12.12.12.2, ::, Serial1/
1.0.0.0/ is subnetted, subnets
C 1.1.1.1 is directly connected, Loopback1
2.0.0.0/ is subnetted, subnets
O 2.2.2.2 [/] via 12.12.12.2, ::, Serial1/
3.0.0.0/ is subnetted, subnets
O IA 3.3.3.3 [/] via 12.12.12.2, ::, Serial1/
4.0.0.0/ is subnetted, subnets
O IA 4.4.4.4 [/] via 12.12.12.2, ::, Serial1/
5.0.0.0/ is subnetted, subnets
O IA 5.5.5.5 [/] via 12.12.12.2, ::, Serial1/ //区域2路由
23.0.0.0/ is subnetted, subnets
O IA 23.23.23.0 [/] via 12.12.12.2, ::, Serial1/
12.0.0.0/ is subnetted, subnets
C 12.12.12.0 is directly connected, Serial1/
45.0.0.0/ is subnetted, subnets
O IA 45.45.45.0 [/] via 12.12.12.2, ::, Serial1/ //区域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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-, L2 - IS-IS level-
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/ is subnetted, subnets
O IA 34.34.34.0 [/] via 12.12.12.2, ::, Serial1/
1.0.0.0/ is subnetted, subnets
C 1.1.1.1 is directly connected, Loopback1
2.0.0.0/ is subnetted, subnets
O 2.2.2.2 [/] via 12.12.12.2, ::, Serial1/
3.0.0.0/ is subnetted, subnets
O IA 3.3.3.3 [/] via 12.12.12.2, ::, Serial1/
4.0.0.0/ is subnetted, subnets
O IA 4.4.4.4 [/] via 12.12.12.2, ::, Serial1/
23.0.0.0/ is subnetted, subnets
O IA 23.23.23.0 [/] via 12.12.12.2, ::, Serial1/
12.0.0.0/ is subnetted, subnets
C 12.12.12.0 is directly connected, Serial1/

总结:在ospf标准配置上增加:

R2 Router-id:2.2.2.2
R4 Router-id:4.4.4.4
R2(config)#area virtual link 4.4.4.4
R4(config)#area virtual link 2.2.2.2