In multi-area OSPF
protocol network, all areas should be connected physically with area 0
(backbone area) for exchanging routing information. But in some cases,
it is not possible to connect directly all areas in a network to
backbone area. In this case, you can use virtual link to create a
connection between backbone area and non backbone area. Basically
virtual link is a logical connection to create virtual adjacency between
two areas using the least cost path.
Two
conditions must be fulfilled to apply a virtual link between different
areas.
Follow the network topology of three different class network in
given figure:

There are some common OSPF configuration and Executable commands:
OSPF configuration on Router A
In global configuration mode
Router-A(config) # router ospf 1 (Here 1 indicate the process
identification number)
Router-A(config-Router) # network 210.100.10.0 0.0.0.255 area 0
(Here 210.100.10.0 indicate the network ID and 0.0.0.255 wildcard mask
with area 0)
Router-A(config-Router) # network 20.0.0.0 0.255.255.255 area 1
(Here 20.0.0.0 indicate the network ID and 0.225.255.255 wildcard mask
with area 1)
Router-A(config-Router) #area 1 virtual-link 31.1.1.1 (Here 1
indicate the area ID and 31.1.1.1 is the highest loopback address of
router B)
Router-A(config-Router) #exit (exit from ospf 1 on router A)
OSPF configuration on Router B
In global configuration mode
Router-B(config) # router ospf 1 (Here 1 indicate the process
identification number)
Router-B(config-Router) # network 210.100.20.0 0.0.0.255 area 1
(Here 210.100.20.0 indicate the network ID and 0.0.0.255 wildcard mask
with area 1)
Router-B(config-Router) # network 20.0.0.0 0.255.255.255 area 1
(Here 20.0.0.0 indicate the network ID and 0.225.255.255 wildcard mask
with area 1)
Router-B(config-Router) # network 30.0.0.0 0.255.255.255 area 2
(Here 30.0.0.0 indicate the network ID and 0.225.255.255 wildcard mask
with area 2)
Router-B(config-Router) #area 1 virtual-link 21.1.1.1 (Here 1
indicate the area ID and 21.1.1.1 is the highest loopback address of
router A)
Router-B(config-Router) #exit (exit from ospf 1 on router B)
OSPF configuration on Router C
In global configuration mode
Router-C(config) # router ospf 2 (Here 2 indicate the process
identification number)
Router-C(config-Router) # network 210.100.30.0 0.0.0.255 area 2
(Here 210.100.30.0 indicate the network ID and 0.0.0.255 wildcard mask
with area 2)
Router-C(config-Router) # network 30.0.0.0 0.255.255.255 area 2
(Here 30.0.0.0 indicate the network ID and 0.225.255.255 wildcard mask
with area 2)
Router-C(config-Router) #exit (exit from ospf 1 on router C)