OSPF Virtual Links Explained
OSPF uses two layers of hierarchy for OSPF areas: the backbone area and the non-backbone area. The backbone area is compulsory. Non-backbone areas are optional. All non-backbone areas must have at least one physical link in the backbone area. If the physical connection is not feasible, you can use a virtual link to connect to the backbone through a non-backbone area.
A virtual link connects a non-backbone area to the backbone area via another non-backbone area having a direct connection to the backbone area. The area the virtual link uses to connect the non-backbone and backbone area is called a transit area. A transit area has the following two requirements:-
- It can not be a stub area.
- It must have the complete routing information.
OSPF Virtual Links (Packet Tracer Example)
Create a practice lab and assign an IP configuration as shown in the following image.

Download Packet Tracer Practice Lab with IP configuration.
OSPF Multi-area configuration
Since a virtual link connects a non-backbone area with the backbone area via another non-backbone area, you need three OSPF areas to practice virtual links. You need two non-backbone areas and one backbone area. You can run a router's interfaces in different OSPF areas. Use the following layout to create two non-backbone areas and one backbone area.

The following commands configure R1's FastEthernet 0/0 in area 0 and FastEthernet 0/1 in area 1.
Router>enable Router#configure terminal Router(config)#router ospf 1 Router(config-router)#network 10.0.0.0 0.255.255.255 area 0 Router(config-router)#network 192.168.1.0 0.0.0.255 area 1 Router(config-router)#exit Router(config)#exit Router#

The following commands configure both interfaces of R2 in area 1.
Router>enable Router#configure terminal Router(config)#router ospf 1 Router(config-router)#network 192.168.1.0 0.0.0.255 area 1 Router(config-router)#exit Router(config)#exit Router#

The following commands configure R3's FastEthernet 0/1 in area 1 and FastEthernet 0/0 in area 2.
Router>enable Router#configure terminal Router(config)#router ospf 1 Router(config-router)#network 20.0.0.0 0.255.255.255 area 2 Router(config-router)#network 192.168.1.0 0.255.255.255 area 1 Router(config-router)#exit Router(config)#exit Router#

With the current configuration, this network will not work. R1 and R2 will not learn about the network 20.0.0.0/8. However, all routers will learn about the network 10.0.0.0/8. You can use the show ip route ospf command to verify it.
Download Packet Tracer Practice Lab with OSPF configuration.
The following image shows the output of this command on R1.

The network 10.0.0.0/8 is available on the Fa0/1 interface of R1. Since the router learns it from the local interface configuration, this command does not include it in the output. The following image shows the output of this command on R2.

The following image shows the output of this command on R3.

To understand why R1 and R2 do not learn about the network 20.0.0.0/8, first, you need to know how OSPF routers exchange routing information. In a multi-area configuration, OSPF routers exchange routing information through the backbone area. Each non-backbone area has at least one ABR (Area Border Router) router. The ABR connects the non-backbone area with the backbone area. The ABR updates the backbone area routers. Then, the backbone area routers share that information with other non-backbone area routers. Routers in different non-backbone areas do not share routing information directly.

In this network, R3 is the ABR for area 2. R2 is the ABR for area 1. R1 is the ABR for area 0. R2 and R3 are responsible for updating R1 about their respective routes. R2 has a direct physical link with R1. It can exchange routing information with area 0. R3 has no direct link with R0. It has no way to update area 0. Since R3 can not update R1, and R2 depends on R1 to get routing information, R2 and R1 do not learn about the routing information R3 has. Even though R2 and R3 have a direct connection, they can not directly share routing information. Since they belong to different OSPF areas, they can share routing information only through the backbone area. A physical link between R3 and R1 is not possible. In this situation, you can create a virtual link between these routers. The following OSPF configuration mode command creates a virtual link.
Router(config-router)# area [area-id] virtual-link [RID]
- The area ID is the ID of the transit area.
- The RID is the RID of the other side router of the virtual link.
Run the above command on both routers that connect via the virtual link. In this example, you will connect R1 with R3 via a virtual link. Hence, you need to run this command on them.

OSPF RID
Since the virtual link setup requires the RID of the other end router, you must configure an RID on both routers. An RID is the identity of the OSFP router. When you start an OSPF router, it checks the following three things to pick the RID:-
- The value of the router-id command
- The highest IP address among all configured IP addresses on Loopback interfaces
- The highest IP address among all configured IP addresses on physical interfaces
The router checks these options in a sequence. If it finds an option's value, it uses that value and does not check the next option. Since you did not configure custom RIDs and loopback interfaces on these routers, they will pick the highest IP address from all IP addresses configured on all physical interfaces. The output of the 'show ip ospf interface' command displays the router's RID. The following image shows the output of this command on R1.

You can also use this command on R2 and R3 to view their RIDs.
Using loopback interfaces for RIDs
A loopback interface always remains up. If you configure a loopback interface and do not configure a custom RID, the router will pick the loopback interface's IP address as the RID. The following commands configure a loopback interface and assign the IP address 1.1.1.1/8 on R1.
Router#configure terminal Router(config)#interface loopback 0 Router(config-if)#ip address 1.1.1.1 255.0.0.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#

The following commands configure a loopback interface and assign the IP address 2.2.2.2/8 on R2.
Router#configure terminal Router(config)#interface loopback 0 Router(config-if)#ip address 2.2.2.2 255.0.0.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#

The following commands configure a loopback interface and assign the IP address 3.3.3.3/8 on R3.
Router#configure terminal Router(config)#interface loopback 0 Router(config-if)#ip address 3.3.3.3 255.0.0.0 Router(config-if)#no shutdown Router(config-if)#exit Router(config)#

An OSPF router picks the RID when it starts. Once it picks the RID, it uses the picked RID until it remains up. Because of this, routers will not choose the new RID until you restart them. Routers keep all running configurations in memory. If you restart a router without saving its running configuration, the running configuration will be lost. The following privileged mode command saves the running configuration.
Router#copy run start
After saving the running configuration on all routers, restart them. The following command restarts the router.
Router#reload
If you are doing this exercise on Packet Tracer, you can save the lab and restart Packet Tracer instead of running the above commands on all routers.
Download Packet Tracer Practice Lab with loopback interface configuration.
The output of the 'show ip ospf interface' command displays the router's RID. You can use this command to verify the new RID. The following image shows the output of this command on R1.

Creating a virtual link
The following commands create and enable a virtual link on R1.
Router(config)#router ospf 1 Router(config-router)#area 1 virtual-link 3.3.3.3

The following commands create and enable a virtual link on R3.
Router(config)#router ospf 1 Router(config-router)#area 1 virtual-link 1.1.1.1

Download the Packet Tracer Practice Lab with the virtual link configuration.
Verifying the virtual link
R3 will use this virtual link to share its routing information with R1. R1 will share the received routing information with R2. You can view the OSPF neighbors and routing table entries on all routers to verify this.
R1

R2

R3

The show ip ospf virtual-links command
The 'show ip ospf virtual-links' command displays the status of all configured virtual links. You can use this command to verify the created virtual link. The following image shows the output of this command on R1.

The following image shows the output of this command on R3.

Verifying the OSPF configuration
You can use the ping command to verify OSPF configuration. The ping command sends ping requests to the destination device. If the destination device is up, it responds to the ping requests. Send ping requests from PC0 to PC1. If PC0 gets replies, it verifies the OSPF configuration.

This tutorial is part of the tutorial "OSPF Configuration and Concepts Explained.". Other parts of this tutorial are as follows:
Chapter 01 OSPF (Open Shortest Path First) Protocol
Chapter 02 RIP V/s OSPF | Differences between RIP and OSPF
Chapter 03 IGP, EGP, and Autonomous System Explained
Chapter 04 OSPF Features, Advantages, Disadvantages
Chapter 05 OSPF Fundamental Terminology Explained
Chapter 06 OSPF LSA Types and LSA Flooding Explained
Chapter 07 OSPF Area Types and Concept Explained
Chapter 08 OSPF Hello Protocol and Packets Explained
Chapter 09 OSPF RID (Router ID) Explained
Chapter 10 OSPF Neighborship Condition and Requirement
Chapter 11 OSPF DR BDR Selection Process Explained
Chapter 12 How OSPF Routers Build Adjacency Explained
Chapter 13 Shortest Path First (SPF) Algorithm Explained
Chapter 14 OSPF Single-Area Configuration Explained
Chapter 15 OSPF Stub area, Totally Stub area, NSSA, and Totally NSSA
Chapter 16 OSPF Virtual Links Explained
Chapter 17 OSPF Authentication Password and MD5 Explained
Chapter 18 OSPF Multi-Area Configuration Explained
Conclusion
In a multi-area environment, routers share routing information via the backbone area. Since the backbone area propagates all routing updates, all non-backbone areas must have a link with the backbone area. If a physical link is not feasible, you can use a virtual link to connect a non-backbone area with the backbone area.
Author Laxmi Goswami Updated on 2026-05-13