OSPF Virtual-Links are used to extend Area 0 to routers without direct connection to OSPF Area 0.
A diagram will help us to understand this requirement a bit better:
The link between R1 F0/0 and R2 F0/0 belongs to the Backbone Area, or Area 0. The Frame-Relay connection between R2 S0/0 and R3 S0/0 belongs to the OSPF Area 1. As far as R2 has a direct connection to Area 0 (through it´s F0/0 interface) no Virtual-Links are needed.
BUT, for example, if we create a Loopback Interface in R3, and place this Loopback Interface in OSPF Area 2, what will happen?!
R3 doesn´t have any connections to Area 0, it has connections to OSPF Areas 1 and 2, but not Area 0. Check this new diagram including the newly created Loopback Interface in R3:
Hmmm... This situation will require the use of Virtual-Links between R3 and R2 using Area 1 as a "connection" to Area 0. In situations like this, where the router (in our case R3) has two or more interfaces in different areas, and none of those interfaces belongs to Area 0, we´ll need to use an OSPF Virtual-Link.
You may ask yourself: why R3 S0/0 in Area 1 doesn´t need a Virtual-Link connection also?! It´s on the same router as the Area 2 Loopback Interface, so why R3´s Loopback in Area 2 need a Virtual-Link connection, but R3´s S0/0 interface in Area 1 doesn´t?!
The answer is simple, R3 is direct connected to R2 using Area 1, and R2 is connected to Area 0, so it´ll get advertised due to R2 connections! ;)
Without Virtual-Links Area 2 (in this situation) would never get advertised to either R2 and R1!
First, let´s go ahead and configure all routers according to our diagram (except by the Virtual-Links):
R1: int f0/0 ip address 192.168.10.1 255.255.255.0 no shut ! router ospf 1 router-id 1.1.1.1 network 192.168.10.0 0.0.0.255 area 0 R2: int f0/0 ip address 192.168.10.2 255.255.255.0 no shut ! int s0/0 encapsulation frame-relay ip address 192.168.11.2 255.255.255.0 frame-relay map ip 192.168.11.3 203 broadcast no shut ! router ospf 1 router-id 2.2.2.2 network 192.168.10.0 0.0.0.255 area 0 network 192.168.11.0 0.0.0.255 area 1 neighbor 192.168.11.2 R3: interface loopback 2 ip address 192.168.12.3 255.255.255.0 ! interface serial 0/0 encapsulation frame-relay ip address 192.168.11.3 255.255.255.0 frame-relay map ip 192.168.11.2 302 broadcast no shut ! router ospf 1 router-id 3.3.3.3 network 192.168.11.0 0.0.0.255 area 1 network 192.168.12.0 0.0.0.255 area 2 neighbor 192.168.11.2 |
Ok! The above configuration is done, let´s check the OSPF Neighbor Relationship and the IP Routing Tables of our routers:
R1: R1(config)#do sh 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 C 192.168.10.0/24 is directly connected, Ethernet0/0 O IA 192.168.11.0/24 [110/74] via 192.168.10.2, 00:00:00, Ethernet0/0 R1(config)#do sh ip ospf neig Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:38 192.168.10.2 Ethernet0/0 ================================================================= R2: R2(config)#do sh 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 C 192.168.10.0/24 is directly connected, Ethernet0/0 C 192.168.11.0/24 is directly connected, Serial1/0 R2(config)#do sh ip ospf neig Neighbor ID Pri State Dead Time Address Interface 1.1.1.1 1 FULL/BDR 00:00:30 192.168.10.1 Ethernet0/0 3.3.3.3 1 FULL/DR 00:01:43 192.168.11.3 Serial1/0 ================================================================= R3: R3#sh 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 C 192.168.12.0/24 is directly connected, Loopback2 O IA 192.168.10.0/24 [110/74]via 192.168.11.2,00:00:24,Serial1/0 C 192.168.11.0/24 is directly connected, Serial1/0 R3#sh ip ospf neig Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DROTHER 00:01:56 192.168.11.2 Serial1/0 |
See?! Neither R1 and R2 have the 192.168.12.0/24 Network from Area 2! That´s because R3 is not directly connected to Area 0! To solve that, we´ll need to configure a Virtual-Link between R2 and R3 using Area 1 as a "connection" to Area 0.
The command to do that is: area <area-id> virtual-link <rid of the router in the other end>, for example: R3 will have the following command added to it´s configuration: area 1 virtual-link 2.2.2.2 . The same command (just changing R2´s rid by R3´s rid) needs to be configured in R2. To make things a little bit easier, here follows the configuration:
R2: router ospf 1 area 1 virtual-link 3.3.3.3 R3: router ospf 1 area 1 virtual-link 2.2.2.2 |
Oh yeah! If you´re unsure about the Router ID (rid) of the router, just issue a show ip ospf command and it´ll show you the Router ID, see below:
R3(config)#do sh ip ospf Routing Process "ospf 1" with ID 3.3.3.3 Supports only single TOS(TOS0) routes Supports opaque LSA Supports Link-local Signaling (LLS) Supports area transit capability Initial SPF schedule delay 5000 msecs <output omitted> |
Now, with the virtual-link configured between R2 and R3, let´s check again the OSPF Neighbor Relationship and the IP Routing Table of all our three routers:
R1: R1(config)#do sh 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 192.168.12.0/32 is subnetted, 1 subnets O IA 192.168.12.3 [110/75] via 192.168.10.2, 00:00:01, Ethernet0/0 C 192.168.10.0/24 is directly connected, Ethernet0/0 O IA 192.168.11.0/24 [110/74] via 192.168.10.2, 00:01:00, Ethernet0/0 R1(config)#do sh ip ospf neig Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 1 FULL/DR 00:00:38 192.168.10.2 Ethernet0/0 ================================================================= R2: R2(config-router)#do sh 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 192.168.12.0/32 is subnetted, 1 subnets O IA 192.168.12.3 [110/65] via 192.168.11.3, 00:00:10, Serial1/0 C 192.168.10.0/24 is directly connected, Ethernet0/0 C 192.168.11.0/24 is directly connected, Serial1/0 R2(config-router)#do sh ip ospf neig Neighbor ID Pri State Dead Time Address Interface 3.3.3.3 0 FULL/- 00:00:33 192.168.11.3 OSPF_VL0 1.1.1.1 1 FULL/BDR 00:00:39 192.168.10.1 Ethernet0/0 3.3.3.3 1 FULL/DR 00:01:56 192.168.11.3 Serial1/0 ================================================================= R3: R3(config-router)#do sh 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 C 192.168.12.0/24 is directly connected, Loopback2 O 192.168.10.0/24 [110/74] via 192.168.11.2, 00:01:41, Serial1/0 C 192.168.11.0/24 is directly connected, Serial1/0 R3(config-router)#do sh ip ospf nei Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 0 FULL/- 00:00:19 192.168.11.2 OSPF_VL1 2.2.2.2 1 FULL/BDR 00:01:47 192.168.11.2 Serial1/0 |
AH! Much better! Now ALL routers have ALL OSPF Routes in their IP Routing Tables! Our "hero" Virtual-Link solved our problem!
Another really usefull tip is... sometimes when you issue a show ip ospf virtual-link the output shows that the Virtual-Link is UP, but you see no communication going on, neither a OSPF Relationship established... well... sometimes that happens, to make sure that the Virtual-Link is "really" working, issue a show ip ospf virtual-link command and see if the output is just a portion of what it´s supposed to be (that will indicate a not working virtual-link) or if you have the full output. That can also be a temporary situation (while the link gets up). See the example of a BAD and a GOOD Virtual-Link output:
Virtual-Link with Problems (BAD): R2(config-router)#do sh ip ospf virtual-link Virtual Link OSPF_VL0 to router 3.3.3.3 is up Run as demand circuit DoNotAge LSA allowed. Transit area 1, via interface Serial1/0, Cost of using 64 Transmit Delay is 1 sec, State POINT_TO_POINT, Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:06 ================================================================= Working Virtual-Link (Good): R2(config-router)#do sh ip ospf virtual-link Virtual Link OSPF_VL0 to router 3.3.3.3 is up Run as demand circuit DoNotAge LSA allowed. Transit area 1, via interface Serial1/0, Cost of using 64 Transmit Delay is 1 sec, State POINT_TO_POINT, Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:08 Adjacency State FULL (Hello suppressed) Index 2/3, retransmission queue length 1, number of retransmission 1 First 0x65593B80(11)/0x0(0) Next 0x65593B80(11)/0x0(0) Last retransmission scan length is 1, maximum is 1 Last retransmission scan time is 0 msec, maximum is 0 msec Link State retransmission due in 2986 msec |
To finish, another useful command (not only to Virtual-Links, but to OSPF), is the show ip ospf interface brief. This command will show you a brief of all OSPF configured interfaces, with some other nice things to know!
R2#sh ip ospf interface brief Interface PID Area IP Address/Mask Cost State Nbrs F/C Et0/0 1 0 192.168.10.2/24 10 DR 1/1 Se1/0 1 1 192.168.11.2/24 64 BDR 1/1 |
Seens a bit easier now, don´t you think?! :) I do!