实验介绍

辅助理解OSPF的虚链路

实验目的

  • 探索VLink的使用

拓扑结构

接口信息

路由器

接口

IP Address/Mask

协议

区域/进程号

R1

GE 0/0/0

10.1.1.1/24

OSPF

Area 0

R2

GE 0/0/0

10.1.1.2/24

OSPF

Area 0

GE 0/0/1

20.1.1.1/24

OSPF

Area 1

R3

GE 0/0/0

20.1.1.2/24

OSPF

Area 1

GE 0/0/1

30.1.1.1/24

OSPF

Area 2

R4

GE 0/0/0

30.1.1.2/24

OSPF

Area 2

GE 0/0/1

40.1.1.1/24

OSPF

Area 3

R5

GE 0/0/0

40.1.1.2/24

OSPF

Area 3

GE 0/0/1

50.1.1.1/24

OSPF

Area 4

R6

GE 0/0/0

50.1.1.2/24

OSPF

Area 4

实验步骤

步骤一:配置基本信息

以R1为例,其余类似

[R1-GigabitEthernet0/0/0]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0
 ip address 10.1.1.1 255.255.255.0
#
return
[R1-LoopBack0]dis th
[V200R003C00]
#
interface LoopBack0
 ip address 1.1.1.1 255.255.255.255
#
return

步骤二:配置OSPF

以R2为例,其余类似

[R2-ospf-1]dis th
[V200R003C00]
#
ospf 1 router-id 2.2.2.2
 area 0.0.0.0
  network 10.1.1.2 0.0.0.0
 area 0.0.0.1
  network 20.1.1.1 0.0.0.0
#
return

配置前

除在区域0的R1和与区域0相连区域1的R3有OSPF路由,其余路由器均学习不到OSPF路由。

[R1]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 1        Routes : 1

OSPF routing table status : <Active>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       20.1.1.0/24  OSPF    10   2           D   10.1.1.2        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0
[R3-ospf-1-area-0.0.0.1]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 1        Routes : 1

OSPF routing table status : <Active>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  OSPF    10   2           D   20.1.1.1        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

同一网段为直连故不通过OSPF学习。

[R2-ospf-1]dis ip routing-table protocol ospf
[R2-ospf-1]
[R6-ospf-1-area-0.0.0.4]dis ip routing-table protocol ospf
[R6-ospf-1-area-0.0.0.4]

配置区域2与区域0的虚链路

配置前

位于区域2的R4学习不到OSPF路由

[R4-ospf-1-area-0.0.0.3]dis ip routing-table protocol ospf
[R4-ospf-1-area-0.0.0.3]
配置虚链路

区域2想要与区域0相连,需要穿过区域1,故要在区域1两端建立虚链路

[R2-ospf-1-area-0.0.0.1]dis th
[V200R003C00]
#
 area 0.0.0.1
  network 20.1.1.1 0.0.0.0
  vlink-peer 3.3.3.3
#
return
[R3-ospf-1-area-0.0.0.1]dis th
[V200R003C00]
#
 area 0.0.0.1
  network 20.1.1.2 0.0.0.0
  vlink-peer 2.2.2.2
#
return
扩展

虚链路创建后的OSPF邻居建立过程中没有2-Way状态,因为早已确定主从关系了。

[R2-ospf-1-area-0.0.0.1]
Oct  2 2025 10:22:04-08:00 R2 %%01OSPF/4/VLINK_NBR_CHG_E(l)[14]:Virtual link peer event: neighbor status changed. (ProcessId=256, VirtualLinkNeighborAddress=3.3.3.3, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[R2-ospf-1-area-0.0.0.1]
Oct  2 2025 10:22:04-08:00 R2 %%01OSPF/4/VLINK_NBR_CHG_E(l)[15]:Virtual link peer event: neighbor status changed. (ProcessId=256, VirtualLinkNeighborAddress=3.3.3.3, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=ExStart)
[R2-ospf-1-area-0.0.0.1]
Oct  2 2025 10:22:04-08:00 R2 %%01OSPF/4/VLINK_NBR_CHG_E(l)[16]:Virtual link peer event: neighbor status changed. (ProcessId=256, VirtualLinkNeighborAddress=3.3.3.3, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
[R2-ospf-1-area-0.0.0.1]
Oct  2 2025 10:22:04-08:00 R2 %%01OSPF/4/VLINK_NBR_CHG_E(l)[17]:Virtual link peer event: neighbor status changed. (ProcessId=256, VirtualLinkNeighborAddress=3.3.3.3, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
[R2-ospf-1-area-0.0.0.1]
Oct  2 2025 10:22:04-08:00 R2 %%01OSPF/4/VLINK_NBR_CHG_E(l)[18]:Virtual link peer event: neighbor status changed. (ProcessId=256, VirtualLinkNeighborAddress=3.3.3.3, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
配置后

R4成功通过OSPF学习到了路由。

至此区域0、区域1和区域2之间能正常通信。

[R4-ospf-1-area-0.0.0.3]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 2        Routes : 2

OSPF routing table status : <Active>
         Destinations : 2        Routes : 2

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  OSPF    10   3           D   30.1.1.1        GigabitEthernet0/0/0
       20.1.1.0/24  OSPF    10   2           D   30.1.1.1        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0
[R1]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 2        Routes : 2

OSPF routing table status : <Active>
         Destinations : 2        Routes : 2

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       20.1.1.0/24  OSPF    10   2           D   10.1.1.2        GigabitEthernet0/0/0
       30.1.1.0/24  OSPF    10   3           D   10.1.1.2        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

配置区域3与区域0的虚链路

配置前

位于区域2的R5学习不到其他OSPF路由

[R5-ospf-1-area-0.0.0.4]dis ip rou p ospf
[R5-ospf-1-area-0.0.0.4]
配置虚链路

区域3想要与区域0相连,需要穿过区域1和区域2,区域1已经配置完虚链路了,故要在区域2两端建立虚链路

[R3-ospf-1-area-0.0.0.2]dis th
[V200R003C00]
#
 area 0.0.0.2
  network 30.1.1.1 0.0.0.0
  vlink-peer 4.4.4.4
#
return
[R4-ospf-1-area-0.0.0.2]dis th
[V200R003C00]
#
 area 0.0.0.2
  network 30.1.1.2 0.0.0.0
  vlink-peer 3.3.3.3
#
return
配置后

R5成功通过OSPF学习到了路由。

至此区域0、区域1、区域2和区域3之间能正常通信。

[R5-ospf-1-area-0.0.0.4]dis ip rou p ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 3        Routes : 3

OSPF routing table status : <Active>
         Destinations : 3        Routes : 3

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  OSPF    10   4           D   40.1.1.1        GigabitEthernet0/0/0
       20.1.1.0/24  OSPF    10   3           D   40.1.1.1        GigabitEthernet0/0/0
       30.1.1.0/24  OSPF    10   2           D   40.1.1.1        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

配置区域3与区域0的虚链路

配置前

位于区域3的R6学习不到OSPF路由

[R6-ospf-1-area-0.0.0.4]dis ip routing-table protocol ospf
[R6-ospf-1-area-0.0.0.4]
配置虚链路

区域4想要与区域0相连,需要穿过区域1、区域2和区域3,区域1和区域2已经配置完虚链路了,故要在区域3两端建立虚链路

[R4-ospf-1-area-0.0.0.3]dis th
[V200R003C00]
#
 area 0.0.0.3
  network 40.1.1.1 0.0.0.0
  vlink-peer 5.5.5.5
#
return
[R5-ospf-1-area-0.0.0.3]dis th
[V200R003C00]
#
 area 0.0.0.3
  network 40.1.1.2 0.0.0.0
  vlink-peer 4.4.4.4
#
return
配置后

R6成功通过OSPF学习到了路由。

至此全部OSPF区域之间能正常通信。

所有的路由器均能通过OSPF学习到全拓扑的明细路由。

[R6-ospf-1]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 4        Routes : 4

OSPF routing table status : <Active>
         Destinations : 4        Routes : 4

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  OSPF    10   5           D   50.1.1.1        GigabitEthernet0/0/0
       20.1.1.0/24  OSPF    10   4           D   50.1.1.1        GigabitEthernet0/0/0
       30.1.1.0/24  OSPF    10   3           D   50.1.1.1        GigabitEthernet0/0/0
       40.1.1.0/24  OSPF    10   2           D   50.1.1.1        GigabitEthernet0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

步骤四:验证

通信验证

R1与R6正常通信

[R1]tracert -a 10.1.1.1 50.1.1.2
 traceroute to  50.1.1.2(50.1.1.2), max hops: 30 ,packet length: 40,press CTRL_C to break
 1 10.1.1.2 30 ms  20 ms  20 ms
 2 20.1.1.2 40 ms  30 ms  20 ms
 3 30.1.1.2 30 ms  30 ms  30 ms
 4 40.1.1.2 60 ms  30 ms  30 ms
 5 50.1.1.2 40 ms  50 ms  40 ms

虚链路详情

在R2上
[R2]dis ospf vlink

         OSPF Process 1 with Router ID 2.2.2.2
                 Virtual Links

 Virtual-link Neighbor-id  -> 3.3.3.3, Neighbor-State: Full

 Interface: 20.1.1.1 (GigabitEthernet0/0/1)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.1
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 GR State: Normal
在R3上
[R3]dis ospf vlink

         OSPF Process 1 with Router ID 3.3.3.3
                 Virtual Links

 Virtual-link Neighbor-id  -> 2.2.2.2, Neighbor-State: Full

 Interface: 20.1.1.2 (GigabitEthernet0/0/0)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.1
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 GR State: Normal

                 Virtual Links

 Virtual-link Neighbor-id  -> 4.4.4.4, Neighbor-State: Full

 Interface: 30.1.1.1 (GigabitEthernet0/0/1)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.2
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 GR State: Normal
在R4上
[R4]dis ospf vlink

         OSPF Process 1 with Router ID 4.4.4.4
                 Virtual Links

 Virtual-link Neighbor-id  -> 3.3.3.3, Neighbor-State: Full

 Interface: 30.1.1.2 (GigabitEthernet0/0/0)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.2
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 GR State: Normal

                 Virtual Links

 Virtual-link Neighbor-id  -> 5.5.5.5, Neighbor-State: Full

 Interface: 40.1.1.1 (GigabitEthernet0/0/1)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.3
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 GR State: Normal
在R5上
[R5]dis ospf vlink

         OSPF Process 1 with Router ID 5.5.5.5
                 Virtual Links

 Virtual-link Neighbor-id  -> 4.4.4.4, Neighbor-State: Full

 Interface: 40.1.1.2 (GigabitEthernet0/0/0)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.3
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 GR State: Normal