Contents

Introduction
Area
    Internal Router
    Backbone Router
    Area Border Router (ABR)
    Autonomous Area Border Router (ASBR)
Neighbor
Designated Router
Network Type
  Form Neighbor Automatically/Manually
  DR/BDR Election
    Timer
    Summary
Link-state Advertisement (LSA)
    Router LSA (Type 1)
    Network LSA (Type 2)
    Network Summary LSA (Type 3)
    ASBR Summary LSA (Type 4)
    External LSA (Type 5)
Stub Area
Not So Stubby Area (NSSA)
Metric and Cost
    ip ospf cost
    Interface Bandwidth
    Reference Bandwidth
    External Route Cost
Path Selection
    Route Type
    Metric
    Load Balancing
Virtual Link
    Connect to Area 0
    Connect two Area 0

Introduction

Open Shortest Path First (OSPF) is one of Link-State Routing Protocol. Each router that participates in OSPF exchanges its own Link-State with the Neighbors. When router receives Link-State from their Neighbors, shortest path is calculated by using Dijkstra Algorithm.

Area

There are lots of things to learn for configuring OSPF. The very first concept that we need to know is Area. OSPF is designed for large scale network. To have a good management, OSPF divides the network into different Area. This is called Hierarchical System. We can express Area by using two different notations. First, we can use a 32bits number, from 0 to 65,535. Or, we can use an IP format, for example, 192.168.1.1. The former one is commonly used. Area 0 (or 0.0.0.0) is a special Area called Backbone Area. All other areas must be connected to Backbone Area. That is the rule!

A picture is worth a thousand words! Please see the following topology and learn some OSPF special terms.

ospf

Internal Router

All interfaces on the router belongs to the same Area, R3 and R5 are Internal Routers.

Backbone Router

At least one interface connect to Backbone Area (Area 0), R2, R3 and R4 are Backbone Routers.

Area Border Router (ABR)

Routers that connect to two or more Areas are called ABR, R2 and R4 are ABR.

Autonomous System Border Routers (ASBR)

If at least one interface of the router is connected to other AS other than OSPF, it is called ASBR. In this topology, another Routing Protocol RIP is running in the blue area. R6 inter-connect OSPF and RIP and it is an ASBR。

Neighbor and Adjacency

Now, try to configure OSPF for the following network.

ospf

IP Settings are as follow,

hostname R1
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
hostname R2
!
interface Ethernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.23.2 255.255.255.0
hostname R3
!
interface Ethernet0/1
 ip address 192.168.23.3 255.255.255.0

Two simple steps to configure OSPF are,

  1. Use router ospf <process id>  to startup OSPF. Unlike EIGRP AS Number, process ID of OSPF is for local only. Two OSPF Neighbor do NOT need to have the same ID。
  2. Use network <network no> <wildcard> area <area id> to declare which Interface will participate in OPSF. Router interfaces that participate in OSPF will send out Hello packets and try to find Neighbors on the network. They will form adjacency if they could and the network that attached to the interface will also be announced after adjacency forms.

So, the basic setting of OSPF will be like this,

hostname R1
!
router ospf 1
 network 192.168.12.0 0.0.0.255 area 10
hostname R2
!
router ospf 1
 network 192.168.12.0 0.0.0.255 area 10
 network 192.168.23.0 0.0.0.255 area 0
hostname R3
!
router ospf 1
 network 192.168.23.0 0.0.0.255 area 0

If success, you will see the following messages showing that they become NeighborNeighbor and the state will change from LOADING to FULL.

*Mar  1 00:10:32.635: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.23.2 on Ethernet0/0 from LOADING to FULL, Loading Done

Actually, there are several states before the routers forming adjacency. Take a look and it will help when troubleshooting.

Down

No Hello Messages.

Init

Just received Hello Message.

2-Way

The two routers is communicating. They will elect DR and BDR (will be explained at the following). Routers that cannot become DR and BDR will be DROTHER and stop at 2-Way. At this time, the two routers form Neighbor.

ExStart

Prepare to exchange Link information.

Exchange

They are exchanging Database Descriptors (DBD). DBD is something like the contents of Link. Check the contents first, and tells Neighbor which Link information you request. And the Neighbor will send you the information by Link State Advertisements (LSA).

Loading

They are exchanging LSAs.

Full

LSA sent completely and the two routers becomes Adjacency. At that time, all Routers in the same area should have same OSPF Topology Table.

If you want to monitor the changes of states, use debug ip ospf adj and then use clear ip ospf process to reset ospf process.

R1#debug ip ospf adj
OSPF adjacency events debugging is on
R1#
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R1#
*Mar  1 00:30:49.891: OSPF: Interface Ethernet0/0 going Down
*Mar  1 00:30:49.891: OSPF: 192.168.12.1 address 192.168.12.1 on Ethernet0/0 is dead, state DOWN
*Mar  1 00:30:49.895: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar  1 00:30:49.899: OSPF: DR/BDR election on Ethernet0/0
*Mar  1 00:30:49.899: OSPF: Elect BDR 192.168.23.2
*Mar  1 00:30:49.903: OSPF: Elect DR 192.168.23.2
*Mar  1 00:30:49.903: OSPF: Elect BDR 192.168.23.2
*Mar  1 00:30:49.907: OSPF: Elect DR 192.168.23.2
*Mar  1 00:30:49.907:        DR: 192.168.23.2 (Id)   BDR: 192.168.23.2 (Id)
*Mar  1 00:30:49.911: OSPF: Flush network LSA immediately
*Mar  1 00:30:49.911: OSPF: Remember old DR 192.168.12.1 (id)
*Mar  1 00:30:49.915: OSPF: 192.168.23.2 address 192.168.12.2 on Ethernet0/0 is dead, state DOWN
*Mar  1 00:30:49.919: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.23.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached

<--Neighbor is started to establish here-->

*Mar  1 00:30:49.923: OSPF: Neighbor change Event on interface Ethernet0/0
*Mar  1 00:30:49.923: OSPF: DR/BDR election on Ethernet0/0
*Mar  1 00:30:49.923: OSPF: Elect BDR 0.0.0.0
*Mar  1 00:30:49.923: OSPF: Elect DR 0.0.0.0
*Mar  1 00:30:49.923:        DR: none    BDR: none
*Mar  1 00:30:49.923: OSPF: Remember old DR 192.168.23.2 (id)
*Mar  1 00:30:49.931: OSPF: Interface Ethernet0/0 going Up
*Mar  1 00:30:49.951: OSPF: 2 Way Communication to 192.168.23.2 on Ethernet0/0, state 2WAY
*Mar  1 00:30:49.951: OSPF: Backup seen Event before WAIT timer on Ethernet0/0
*Mar  1 00:30:49.955: OSPF: DR/BDR election on Ethernet0/0
*Mar  1 00:30:49.955: OSPF: Elect BDR 192.168.12.1
*Mar  1 00:30:49.959: OSPF: Elect DR 192.168.23.2
*Mar  1 00:30:49.959: OSPF: Elect BDR 192.168.12.1
*Mar  1 00:30:49.963: OSPF: Elect DR 192.168.23.2
*Mar  1 00:30:49.963:        DR: 192.168.23.2 (Id)   BDR: 192.168.12.1 (Id)
*Mar  1 00:30:49.967: OSPF: Send DBD to 192.168.23.2 on Ethernet0/0 seq 0x20AD opt 0x52 flag 0x7 len 32
*Mar  1 00:30:50.111: OSPF: Rcv DBD from 192.168.23.2 on Ethernet0/0 seq 0x241F opt 0x52 flag 0x7 len 32  mtu 1500 state EXSTART
*Mar  1 00:30:50.115: OSPF: NBR Negotiation Done. We are the SLAVE
*Mar  1 00:30:50.115: OSPF: Send DBD to 192.168.23.2 on Ethernet0/0 seq 0x241F opt 0x52 flag 0x0 len 32
*Mar  1 00:30:50.143: OSPF: Rcv DBD from 192.168.23.2 on Ethernet0/0 seq 0x2420 opt 0x52 flag 0x3 len 72  mtu 1500 state EXCHANGE
*Mar  1 00:30:50.147: OSPF: Send DBD to 192.168.23.2 on Ethernet0/0 seq 0x2420 opt 0x52 flag 0x0 len 32
*Mar  1 00:30:50.175: OSPF: Rcv DBD from 192.168.23.2 on Ethernet0/0 seq 0x2421 opt 0x52 flag 0x1 len 32  mtu 1500 state EXCHANGE
*Mar  1 00:30:50.175: OSPF: Exchange Done with 192.168.23.2 on Ethernet0/0
*Mar  1 00:30:50.175: OSPF: Send LS REQ to 192.168.23.2 length 24 LSA count 2
*Mar  1 00:30:50.175: OSPF: Send DBD to 192.168.23.2 on Ethernet0/0 seq 0x2421 opt 0x52 flag 0x0 len 32
*Mar  1 00:30:50.191: OSPF: Rcv LS UPD from 192.168.23.2 on Ethernet0/0 length 92 LSA count 2
*Mar  1 00:30:50.199: OSPF: Synchronized with 192.168.23.2 on Ethernet0/0, state FULL

<--Output Omitted-->

A very importat command: show ip ospf neighbor. You can see the Neighbor status. The following results should be shown if enter at R2:

R2#show ip ospf Neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.23.3      1   FULL/DR         00:00:35    192.168.23.3    Ethernet0/1
192.168.12.1      1   FULL/BDR        00:00:32    192.168.12.1    Ethernet0/0

The meanings of each fields are as follow,

Neighbor ID

You may say it is the name of the Neighbor. It is the name but not IP address! OSPF routers use the following priority to choose its name.

  1. Use router-id setting.
  2. If no router-id is set, use the largest IP Address in Loopback interface.
  3. If no Loopback interface is set, use the largest IP Address of the interface that participate in OSPF.

So if you want to set a Router ID, use the following command (reset OSPF after configuration),

R1(config)#router ospf 1
R1(config-router)#router-id 1.2.3.4
Reload or use "clear ip ospf process" command, for this to take effect
R1(config-router)#do clear ip ospf process
Reset ALL OSPF processes? [no]: yes

Then, check Neighbor at R2 and you will see the Router ID has been changes.

R2#show ip ospf Neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.23.3      1   FULL/DR         00:00:38    192.168.23.3    Ethernet0/1
1.2.3.4           1   FULL/BDR        00:00:38    192.168.12.1    Ethernet0/0

Pri

Priority is used to decide who will become the DR. Router with higher priority becomes the DR, and the second higher will become the BDR. Routers that are not BR and BDR will become DROTHER. We will explain what is DR and BDR in the following session.

State

It shows two meanings. The former is the state of Neighbor. Full is good and means that the two Neighbors form adjacency. The latter is the role of the Neighbor. Is it a DR / BDR or DROTHER? In Broadcast Multi-Access network such as Ethernet, there may have 3 or more routers connect together in a network. To have fully mesh connection, each router need to establish n-1 connections and total connection will be n(n-1)/2. OSPF do not want to build such large amount of connections. A DR (Designated Router) is chosen and all other routers send update to DR if there are any routing updates. Then, DR will pass the updates to all routers. By using this method, all routers (except DR) in this area only need to have one connection. A BDR (Backup Designated Router) is also chosen to become the successor in case the DR is down.

Dead Time

The default Hello Interval is 10 seconds. When a router receives Hello Message from Neighbor, it replies. If the router does not reply after 40 seconds (which is called Dead Interval), it is assumed that the router is down. So, this timer will always countdown from 40 seconds until it receives a reply. The timer resets to 40 again when receives a reply. If the timer goes to 0 and still do not receive a reply, it will assume that the Neighbor is down.

We can change the Hello Interval and Dead Interval in interface mode. Make sure that the two Neighbor should have the same interval values.

R1(config-if)# ip ospf hello-interval 15
R2(config-if)# ip ospf dead-interval 60 

Address

The IP address of Neighbor. Different to Neighbor ID, it is really an IP address.

Criteria to become Neighbors

To become Neighbors, the OSPF parameters of interfaces of the two routers must be same. They include,

Area ID

If my interface is in Area 0 and yours is in Area 10, we cannot form Neighbor. Area ID must be same.

Area Type

There are six area types in OSPF, those are Backbone Area (Area 0), Standard Area, Stub Area, Totally Stubby Area, Not-so-stubby Area and Totally Not-so-stubby Area. We will discuss it later.

Prefix and Subnet Mask

The Prefix and Subnet Mask of the Interface must be same. It means that the interface should be in the same network to form Neighbor.

Interval Timer

As we said before, Hello Interval and Dead Interval must be same.

Authentication

For security, password authentication can be set for OSPF. Two routers become Neighbors only if the passwords are same. OSPF supports plain text password or MD5 password.

For plain text password, use the following commands,

R1(config)# router ospf 1
R1(config-router)# network 192.168.12.0 0.0.0.255 area 10
R1(config-router)# area 10 authentication 

And set the password at interface.

R1(config)# interface Ethernet0/0
R1(config-if)# ip ospf authentication
R1(config-if)# ip ospf authentication-key MyPassword 

For MD5 password, use the following commands,

R1(config)# router ospf 1
R1(config-router)# network 192.168.12.0 0.0.0.255 area 10
R1(config-router)# area 10 authentication message-digest 

And set the password at interface.

R1(config)# interface Ethernet0/0
R1(config-router)# ip ospf message-digest-key 10 md5 MyPassword 

Designated Router

We are going to talk about the election of DR and BDR now. Choose a router with higher performance to becomes DR can improve stability.

In a network segment, router with higher priority becomes the DR, the second highest becomes the BDR. If the priority are same, highest Router ID wins. Let us see the following example, 4 routers are connected to the same network segment.

ospf

Router settings,

hostname R1
!
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
!
router ospf 1
 network 192.168.1.0 0.0.0.255 area 0
hostname R2
!
interface Ethernet0/0
 ip address 192.168.1.2 255.255.255.0
!
router ospf 1
 network 192.168.1.0 0.0.0.255 area 0
hostname R3
!
interface Ethernet0/0
 ip address 192.168.1.3 255.255.255.0
!
router ospf 1
 network 192.168.1.0 0.0.0.255 area 0
hostname R4
!
interface Ethernet0/0
 ip address 192.168.1.4 255.255.255.0
!
router ospf 1
 network 192.168.1.0 0.0.0.255 area 0

Check Neighbor Table on R1, the priority of all routers are 1 (default). Use show ip ospf interface <interface> to check the priority of R1, it is also 1. Since all priority are same, the router with router ID 192.168.1.4 becomes the DR since it is the largest. The second highest 192.168.1.3 becomes the BDR.

R1#show ip ospf Neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.1.2       1   FULL/DROTHER    00:00:38    192.168.1.2     Ethernet0/0
192.168.1.3       1   FULL/BDR        00:00:38    192.168.1.3     Ethernet0/0
192.168.1.4       1   FULL/DR         00:00:37    192.168.1.4     Ethernet0/0

R1#show ip ospf interface ethernet 0/0
Ethernet0/0 is up, line protocol is up
  Internet Address 192.168.1.1/24, Area 0
  Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DROTHER, Priority 1
  Designated Router (ID) 192.168.1.4, Interface address 192.168.1.4
  Backup Designated router (ID) 192.168.1.3, Interface address 192.168.1.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:01
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 3, Adjacent Neighbor count is 2
    Adjacent with Neighbor 192.168.1.3  (Backup Designated Router)
    Adjacent with Neighbor 192.168.1.4  (Designated Router)
  Suppress hello for 0 Neighbor(s)

To change the priority, use ip ospf priority <priority> at interface mode. Try to change the priority of R1 to 100.

R1(config)#interface ethernet 0/0
R1(config-if)#ip ospf priority 100

Although priority have been changed, R1 is still DROTHER but not DR. Because the role of a DR is not changed after the election. If we want R1 to be the DR, reset the OSPF process at R4.

R1#show ip ospf interface ethernet 0/0
Ethernet0/0 is up, line protocol is up
  Internet Address 192.168.1.1/24, Area 0
  Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DROTHER, Priority 100

<--output omitted-->

Use clear ip ospf process to reset OSPF Process。

R4#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R4#
*Mar  1 00:28:41.175: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.1 on Ethernet0/0 from 2WAY to DOWN, Neighbor Down: Interface down or detached
*Mar  1 00:28:41.179: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.2 on Ethernet0/0 from 2WAY to DOWN, Neighbor Down: Interface down or detached
*Mar  1 00:28:41.179: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.3 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached

Check R1 again. It becomes BDR but not DR, why??

R1#show ip ospf interface ethernet 0/0
Ethernet0/0 is up, line protocol is up
  Internet Address 192.168.1.1/24, Area 0
  Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State BDR, Priority 100

<--output omitted-->

Wen R4 is down due to reset OSPF, R3 is promoted to DR from its original role BDR and R1 is promoted from DROTHER to BDR. Only reset OSPF process again at R3 to make R1 to become DR. This is a good mechanism to improve stability. After reset R3, R4 becomes the new BDR since it has a higher router ID.

Reset ALL OSPF processes? [no]: yes
R3#
*Mar  1 00:32:04.415: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.1 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Mar  1 00:32:04.419: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.2 on Ethernet0/0 from 2WAY to DOWN, Neighbor Down: Interface down or detached
*Mar  1 00:32:04.419: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.4 on Ethernet0/0 from EXSTART to DOWN, Neighbor Down: Interface down or detached
R3#
*Mar  1 00:32:04.515: %OSPF-4-NONEIGHBOR: Received database description from unknown Neighbor 192.168.1.4
R3#
*Mar  1 00:32:12.799: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.1 on Ethernet0/0 from LOADING to FULL, Loading Done
*Mar  1 00:32:12.995: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.4 on Ethernet0/0 from LOADING to FULL, Loading Done

R1 becomes DR.

R1#show ip ospf interface ethernet 0/0
Ethernet0/0 is up, line protocol is up
  Internet Address 192.168.1.1/24, Area 0
  Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 100

<--output omitted-->

Chect at R2, R1 is the DR now.

R2#show ip ospf Neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.1.1     100   FULL/DR         00:00:30    192.168.1.1     Ethernet0/0
192.168.1.3       1   FULL/DROTHER    00:00:37    192.168.1.3     Ethernet0/0
192.168.1.4       1   FULL/BDR        00:00:35    192.168.1.4     Ethernet0/0

Network Type

Up to this point, we have learned three elements of OSPF Neighbor,

  1. Router search Neighbor automatically by using Multicast.
  2. Election process of DR/BDR (Compare Priority first, and then Router ID)
  3. Timer (Hello Interval and Dead Interval), default 10/40 seconds

OSPF will tune these three elements depends on different network environment.

Form Neighbor Automatically / Manually

OSPF use Multicast to discover Neighbors automatically. If network do not support Broadcast equals that it does not support Multicast. Then, how does this network find Neighbors? We know that Ethernet do support Broadcast. How about Frame Relay, support Broadcast or not? The answer is YES and NO! Because The Broadcast feature of Frame Relay Network can be turned on or off. If the Broadcast feature is turned off, we need to set the Neighbors manually.

Another type of network is called Point to Point Network. Although there is no Broadcast in Point to Point Network, Neighbors can still be established automatically. Since there are only two nodes in Point to Point Network, they know each other and established Neighbor automatically. Serial Interface Point to Point Connection is an example of Point to Point Network.

So, the result is,

Non-Broadcast Network do NOT discover Neighbors automatically, manually setting is needed.

We will use a Multipoint Non-Broadcast Frame Relay Network as a demo to show you how to set Neighbors manually. If you are not familiar with Frame Relay, take a look at Frame Relay Switching.

ospf

hostname R1
!
interface Serial0/0
 ip address 192.168.123.1 255.255.255.0
 encapsulation frame-relay
 frame-relay map ip 192.168.123.2 102
 frame-relay map ip 192.168.123.3 103
hostname R2
!
interface Serial0/0
 ip address 192.168.123.2 255.255.255.0
 encapsulation frame-relay
 frame-relay map ip 192.168.123.1 201
 frame-relay map ip 192.168.123.3 201
hostname R3
!
interface Serial0/0
 ip address 192.168.123.3 255.255.255.0
 encapsulation frame-relay
 frame-relay map ip 192.168.123.1 301
 frame-relay map ip 192.168.123.2 301

Because we did not enter the keyword Broadcast at frame-relay command, it does not support Broadcast. We try to run OSPF command on these routers.

hostname R1
!
router ospf 1
 network 192.168.123.0 0.0.0.255 area 0
hostname R2
!
router ospf 1
 network 192.168.123.0 0.0.0.255 area 0
hostname R3
!
router ospf 1
 network 192.168.123.0 0.0.0.255 area 0

But no Neighbor is found. Of course, we need to enter it manually.

R1(config)#router ospf 1
R1(config-router)#Neighbor 192.168.123.2
R1(config-router)#Neighbor 192.168.123.3
R1(config-router)#
*Mar  1 00:28:05.083: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.123.2 on Serial0/0 from LOADING to FULL, Loading Done
*Mar  1 00:28:06.083: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.123.3 on Serial0/0 from LOADING to FULL, Loading Done

DR/BDR Election

Is DR election a must? We explain that the purpose of DR election is to minimize the number of connections in case there are lots of routers. How about if we only have 2 routers in a network segment? Yes, we do not need election. So, only Multi Access Network that have more than two routers in a network segemnt needs DR. Other than Ethernet, are there any Multi Access network else?

For instance, Multipoint Frame Relay Network is a fully mesh topology that connected by Frame Relay Switches. It is not Ethernet but routers can access each other like Ethernet.

ospf

So, the result is,

All Multi-Access Network NEED DR/BDR Election.

Do you remember that we can affect the DR/BDR election? We can use ip ospf priority to change the priority to control the results. But, the priority is transferred by Hello Message. Hello Message depends on Broadcast. A Non-Broadcast network that do not support Broadcast needs another method to define the priority as follow.

R1(config)#router ospf 1
R1(config-router)#Neighbor 192.168.123.2 priority 50
R1(config-router)#Neighbor 192.168.123.3 priority 100

Timer

The bandwidth and delay varies in different network. The default timer 10/40 seconds is only for fast network like Broadcase Multicast and Point-to-Point Network. It may be too short for some slow network. We can change to 40/120 seconds for slow network type.

Only Broadcast Multicast and Point-to-Point Network use default Timer 10/40. The timer for other network is 30/120。

Summary

Form Neighbor Automatically/Manually, DR/BDR Election, 10,40 / 30,120 Timer, Cisco Router will group these three elements into 5 groups which called Network Type. The different of Network Type are listed in the following table.

 Non-Broadcast Multi-access (NBMA)Multipoint BroadcastMultipoint Non-BroadcastBroadcast Multi-accessPoint-to-Point
DR/BDR Election Yes No No Yes No
Neighbor Auto-discovery No Yes No Yes Yes
Hello / Dead Interval 30 / 120 30 / 120 30 / 120 10 / 40 10 / 40
Example Fully Mesh Frame Relay Multipoint Frame Relay (with Broadcast Keyword) Multipoint Frame Relay (without Broadcast Keyword) Ethernet Serial Interface Point to Point Connection

For Ethernet Interface, the default network type is Broadcast Multi-access. Use show ip ospf interface to check.

R1#show ip ospf interface
Ethernet0/0 is up, line protocol is up
  Internet Address 192.168.12.1/24, Area 0
  Process ID 1, Router ID 192.168.12.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.12.1, Interface address 192.168.12.1
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:05
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 0
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 0, Adjacent Neighbor count is 0
  Suppress hello for 0 Neighbor(s)

Enter command ip ospf network <network type> at interface to change Network Type.

R1(config)#interface ethernet 0/0
R1(config-if)#ip ospf network ?
  broadcast            Specify OSPF broadcast multi-access network
  non-broadcast        Specify OSPF NBMA network
  point-to-multipoint  Specify OSPF point-to-multipoint network
  point-to-point       Specify OSPF point-to-point network

R1(config-if)#ip ospf network non-broadcast
R1(config-if)#end
R1#show ip ospf interface
Ethernet0/0 is up, line protocol is up
  Internet Address 192.168.12.1/24, Area 0
  Process ID 1, Router ID 192.168.12.1, Network Type NON_BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State WAITING, Priority 1
  No designated router on this network
  No backup designated router on this network
  Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
    oob-resync timeout 120
    Hello due in 00:00:17
    Wait time before Designated router selection 00:01:17
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 0
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 0, Adjacent Neighbor count is 0
  Suppress hello for 0 Neighbor(s)

Link-state Advertisement (LSA)

OSPF is one of Link-state Routing Protocol. Link is the Interface of Router. The concept of OSPF is to tell each other what network they are connecting by using LSA. Then, each router will calculate its Route Table by the received information. There is much information included in the LSA. For example, the originator of LSA, what Network is connecting, and the cost of arriving the network (Cost is use to decide which path is shorter when multipath is available, we will discuss it in the Cost session). Routers collect all these information to calculate the cost of path. There are different types of LSA. We will use the following topology to explain one by one. We have already expressed the setting of OSPF before so we do not repeat again. Also, we have set the Loopback Interface IP for each router. R1 is 1.1.1.1, R2 is 2.2.2.2 and so on.

ospf

hostname R1
!
router ospf 1
 network 192.168.12.0 0.0.0.255 area 10
hostname R2
!
router ospf 1
 network 192.168.12.0 0.0.0.255 area 10
 network 192.168.23.0 0.0.0.255 area 0
 network 192.168.28.0 0.0.0.255 area 0
hostname R3
!
router ospf 1
 network 192.168.23.0 0.0.0.255 area 0
 network 192.168.34.0 0.0.0.255 area 0
hostname R4
!
router ospf 1
 network 192.168.34.0 0.0.0.255 area 0
 network 192.168.48.0 0.0.0.255 area 0
 network 192.168.45.0 0.0.0.255 area 20
hostname R5
!
router ospf 1
 network 192.168.45.0 0.0.0.255 area 20
 network 192.168.56.0 0.0.0.255 area 20

For R6, we have used the redistribute command. However, redistribute is not in scope of this article. I am not going to explain too much in redistribute now. Just remember that the function of redistribute is to import RIP route into OSPF. On the other hand, it also import OSPF route into RIP.

hostname R6
!
router ospf 1
 redistribute rip subnets
 network 192.168.56.0 0.0.0.255 area 20
!
router rip
 version 2
 redistribute ospf 1 metric 1
 network 192.168.67.0

R7 only run RIP and it is not a part of OSPF Network.

hostname R7
!
router rip
 version 2
 network 192.168.67.0
hostname R8
!
router ospf 1
 network 192.168.28.0 0.0.0.255 area 0
 network 192.168.48.0 0.0.0.255 area 0

Router LSA (Type 1)

Router LSA is received from all router (including the router on its own) in the same Area. We can use show ip ospf database router to show Router LSA. At the following example, R1 received two Type 1 LSA. Check Advertising Router and you will see that the first one is originated by 1.1.1.1 (own) and the other one is originated by 2.2.2.2. Focus on the second one, what did 2.2.2.2 tell R1 are,

  1. I am an ABR
  2. I would like to tell you that I have a Link called 192.168.12.2, and the Cost to going there is 10.
R1#show ip ospf 1 database router

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 10)

  LS age: 234
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 1.1.1.1
  Advertising Router: 1.1.1.1
  LS Seq Number: 80000002
  Checksum: 0x1C18
  Length: 36
  Number of Links: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.12.1
     (Link Data) Router Interface address: 192.168.12.1
      Number of TOS metrics: 0
       TOS 0 Metrics: 10


  Routing Bit Set on this LSA
  LS age: 254
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 2.2.2.2
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xE049
  Length: 36
  Area Border Router
  Number of Links: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 192.168.12.1
     (Link Data) Router Interface address: 192.168.12.2
      Number of TOS metrics: 0
       TOS 0 Metrics: 10

Network LSA (Type 2)

The DR of a network segment sends Network LSA to other routers. Type show ip ospf database network to check Type 2 LSA. R1 received Type 2 from the DR, that is R2. We can see that R2 is connecting to 1.1.1.1 and 2.2.2.2 (the DR).

R1#show ip ospf Neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:35    192.168.12.2    Ethernet0/0
R1#
R1#show ip ospf 1 database network

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Net Link States (Area 10)

  Routing Bit Set on this LSA
  LS age: 26
  Options: (No TOS-capability, DC)
  LS Type: Network Links
  Link State ID: 192.168.12.2 (address of Designated Router)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000001
  Checksum: 0x8F1F
  Length: 32
  Network Mask: /24
        Attached Router: 2.2.2.2
        Attached Router: 1.1.1.1

Network Summary LSA (Type 3)

Type 3 is originated by ABR, it tells the routers located in this Area that which Network the ABR can reach and the cost of going there. To check Type 3 LSA, use show ip ospf database summary. R1 received six Type 3 from R2 (2.2.2.2). R2 tells that,

  1. I can reach 192.168.23.0, and the cost is 10.
  2. I can reach 192.168.28.0, and the cost is 10.
  3. I can reach 192.168.34.0, and the cost is 20.
  4. I can reach 192.168.45.0, and the cost is 30.
  5. I can reach 192.168.48.0, and the cost is 20.
  6. I can reach 192.168.56.0, and the cost is 40.
R1#show ip ospf 1 database summary

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Summary Net Link States (Area 10)

  Routing Bit Set on this LSA
  LS age: 207
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 192.168.23.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xFFA9
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 10

  Routing Bit Set on this LSA
  LS age: 125
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 192.168.28.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000001
  Checksum: 0xCADA
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 10

  Routing Bit Set on this LSA
  LS age: 207
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 192.168.34.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xEAA9
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 20

  Routing Bit Set on this LSA
  LS age: 213
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 192.168.45.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xD5A9
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 30

  Routing Bit Set on this LSA
  LS age: 90
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 192.168.48.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0x5036
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 20

  Routing Bit Set on this LSA
  LS age: 218
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 192.168.56.0 (summary Network Number)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xC0A9
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 40

ASBR Summary (Type 4)

ABR also sent out ASBR Summary to tell the router that located in the Area that which ASBR it can reach and the cost of going there. To see Type 4 LSA, use show ip ospf database asbr-summary. For example on R1, it received one Type 4 telling it R2 can reach an ASBR called 6.6.6.6 and the cost is 40.

R1#show ip ospf 1 database asbr-summary

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Summary ASB Link States (Area 10)

  Routing Bit Set on this LSA
  LS age: 701
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(AS Boundary Router)
  Link State ID: 6.6.6.6 (AS Boundary Router address)
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xB939
  Length: 28
  Network Mask: /0
        TOS: 0  Metric: 40

External LSA (Type 5)

External LSA is originated by ASBR to tell all Area (except Stub Area, we will explain it later) that it is connecting to some External Network (means other Routing Protocol but not this OSPF). Use show ip ospf database external to check Type 5 LSA. R1 received a Type 5 from R6 (6.6.6.6) telling that R6 can reach 192.168.67.0 network and the cost is 20. The metric Type is E2. What is Metric Type? Tell you later in the Cost session.

R1#show ip ospf 1 database external

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Type-5 AS External Link States

  LS age: 14
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: 192.168.67.0 (External Network Number )
  Advertising Router: 6.6.6.6
  LS Seq Number: 80000003
  Checksum: 0x9940
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        TOS: 0
        Metric: 20
        Forward Address: 0.0.0.0
        External Route Tag: 0

By collecting these LSAs, OSPF routers can calculate the Route Table. Check the Route Table on R3, the route that coming from OSPF will have the code O. IA means Intra Area Route. E1 and E2 mean External Route that is from other Routing Protocol and need an ASBR to going there. 110 is the AD (Administrative Distance) and the number that followed by AS is the OSPF Metric. OSPF Metric is related to the cost and we will explain in the Cost session.

R3#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 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

O IA 192.168.12.0/24 [110/20] via 192.168.23.2, 00:10:51, Ethernet0/1
O    192.168.28.0/24 [110/20] via 192.168.23.2, 00:10:51, Ethernet0/1
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
O IA 192.168.45.0/24 [110/20] via 192.168.34.4, 00:10:51, Ethernet0/0
O IA 192.168.56.0/24 [110/30] via 192.168.34.4, 00:10:51, Ethernet0/0
C    192.168.23.0/24 is directly connected, Ethernet0/1
O E2 192.168.67.0/24 [110/20] via 192.168.34.4, 00:10:51, Ethernet0/0
C    192.168.34.0/24 is directly connected, Ethernet0/0
O    192.168.48.0/24 [110/20] via 192.168.34.4, 00:10:56, Ethernet0/0

And there is a LSA called Type 7 that will be explained in the session NSSA. The summary of LSA is as below,

 Type 1Type 2Type 3Type 4Type 5Type 7
Originated by All routers DR of each network segment ABR ABR ASBR ASBR
Received by Routers in the same Area Non-DR router in the same Area All routers in the same Area All routers in the same Area All routers in the OSPF All routers in NSSA
Information Connected Network Router connected by DR Connected Network in other Area ASBR Information External Network Information External Network Information

Stub Area

ospf

Use the same topology and check the Route Table and OSPF Database at R1.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O IA 192.168.28.0/24 [110/20] via 192.168.12.2, 00:26:29, Ethernet0/0
O IA 192.168.45.0/24 [110/40] via 192.168.12.2, 01:19:14, Ethernet0/0
O IA 192.168.56.0/24 [110/50] via 192.168.12.2, 01:19:14, Ethernet0/0
O IA 192.168.23.0/24 [110/20] via 192.168.12.2, 01:19:14, Ethernet0/0
O E2 192.168.67.0/24 [110/20] via 192.168.12.2, 00:26:01, Ethernet0/0
O IA 192.168.34.0/24 [110/30] via 192.168.12.2, 01:19:14, Ethernet0/0
O IA 192.168.48.0/24 [110/30] via 192.168.12.2, 00:25:48, Ethernet0/0

R1#show ip ospf 1 database

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         11          0x8000000A 0x009A8A 2
2.2.2.2         2.2.2.2         17          0x80000009 0x00DC45 1

                Net Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.1    1.1.1.1         21          0x80000001 0x00C7EB
192.168.12.2    2.2.2.2         17          0x80000007 0x008325

                Summary Net Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.23.0    2.2.2.2         22          0x80000006 0x00F7AD
192.168.28.0    2.2.2.2         22          0x80000004 0x00C4DD
192.168.34.0    2.2.2.2         22          0x80000006 0x00E2AD
192.168.45.0    2.2.2.2         22          0x80000006 0x00CDAD
192.168.48.0    2.2.2.2         22          0x80000005 0x004A39
192.168.56.0    2.2.2.2         22          0x80000006 0x00B8AD

                Summary ASB Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
6.6.6.6         2.2.2.2         26          0x80000001 0x00BB38

                Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
192.168.67.0    6.6.6.6         1282        0x80000004 0x009741 0

It seems good! R1 received LSAs from Type 1 to Type 5 and it can reach all networks. However…….there are something strange. Please think, to R1, wherever it wants to go, it use 192.168.12.2 as the Next Hop. So, why it needs to remember such number of routes in its route table? The very smart OSPF designer uses Stub Area to simplify it. Now, let us change Area 10 to Stub Area. Just add area <area no> stub in the OSPF configuration.

hostname R1
!
router ospf 1
 area 10 stub
 network 192.168.12.0 0.0.0.255 area 10
hostname R2
!
router ospf 1
 area 10 stub
 network 192.168.12.0 0.0.0.255 area 10
 network 192.168.23.0 0.0.0.255 area 0
 network 192.168.28.0 0.0.0.255 area 0

Check the Route Table again in R1, External Route is replaced by a Default Route O*IA.

R1#show ip route | begin Gateway
Gateway of last resort is 192.168.12.2 to network 0.0.0.0

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O IA 192.168.28.0/24 [110/20] via 192.168.12.2, 00:00:06, Ethernet0/0
O IA 192.168.45.0/24 [110/40] via 192.168.12.2, 00:00:06, Ethernet0/0
O IA 192.168.56.0/24 [110/50] via 192.168.12.2, 00:00:06, Ethernet0/0
O IA 192.168.23.0/24 [110/20] via 192.168.12.2, 00:00:06, Ethernet0/0
O IA 192.168.34.0/24 [110/30] via 192.168.12.2, 00:00:06, Ethernet0/0
O IA 192.168.48.0/24 [110/30] via 192.168.12.2, 00:00:06, Ethernet0/0
O*IA 0.0.0.0/0 [110/11] via 192.168.12.2, 00:00:06, Ethernet0/0

Check OSPF Database. Stub Area have blocked Type 4 and Type 5 LSAs and the ABR generated a Type 3 Default Route 0.0.0.0 so that we have the default router on R1.

R1#show ip ospf 1 database

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         140         0x8000000C 0x0030FA 1
2.2.2.2         2.2.2.2         138         0x8000000B 0x00F62B 1

                Net Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.2    2.2.2.2         138         0x80000009 0x009D0B

                Summary Net Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
0.0.0.0         2.2.2.2         143         0x80000001 0x0075C0
192.168.23.0    2.2.2.2         143         0x80000007 0x001492
192.168.28.0    2.2.2.2         143         0x80000005 0x00E0C2
192.168.34.0    2.2.2.2         143         0x80000007 0x00FE92
192.168.45.0    2.2.2.2         143         0x80000007 0x00E992
192.168.48.0    2.2.2.2         143         0x80000006 0x00661E
192.168.56.0    2.2.2.2         143         0x80000007 0x00D492

It is good but……can we do a little bit more? Try the Totally Stubby Area. Add the keyword no-summary after stub.

hostname R1
!
router ospf 1
 area 10 stub no-summary
 network 192.168.12.0 0.0.0.255 area 10
hostname R2
!
router ospf 1
 area 10 stub no-summary
 network 192.168.12.0 0.0.0.255 area 10
 network 192.168.23.0 0.0.0.255 area 0
 network 192.168.28.0 0.0.0.255 area 0

The changes of the OSPF Database at R1.

R1#show ip ospf 1 database

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         465         0x8000000C 0x0030FA 1
2.2.2.2         2.2.2.2         462         0x8000000B 0x00F62B 1

                Net Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.2    2.2.2.2         462         0x80000009 0x009D0B

                Summary Net Link States (Area 10)

Link ID         ADV Router      Age         Seq#       Checksum
0.0.0.0         2.2.2.2         81          0x80000002 0x0073C1

Totally Stubby Area blocks Type 3 as well as Type 4 and Type 5, the Route Table will become,

R1#show ip route | begin Gateway
Gateway of last resort is 192.168.12.2 to network 0.0.0.0

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O*IA 0.0.0.0/0 [110/11] via 192.168.12.2, 00:02:37, Ethernet0/0

As you can see, Stub Area and Totally Stubby Area can reduce the transmission of LSAs to decrease network loading. It also simplifies the Route Table to make the life easier. But please be reminded that Stub Area and Totally Stubby Area are only suitable for the area that do not connect to External Network.

Not So Stubby Area (NSSA)

ospf

We are going to discuss Area 20 in this session. Check the Route Table and OSPF Database on R5 first.

R5#show ip route | begin Gateway
Gateway of last resort is not set

O IA 192.168.12.0/24 [110/40] via 192.168.45.4, 00:18:55, Ethernet0/1
O IA 192.168.28.0/24 [110/30] via 192.168.45.4, 00:57:29, Ethernet0/1
C    192.168.45.0/24 is directly connected, Ethernet0/1
     5.0.0.0/32 is subnetted, 1 subnets
C       5.5.5.5 is directly connected, Loopback0
C    192.168.56.0/24 is directly connected, Ethernet0/0
O IA 192.168.23.0/24 [110/30] via 192.168.45.4, 01:15:58, Ethernet0/1
O E2 192.168.67.0/24 [110/20] via 192.168.56.6, 00:58:12, Ethernet0/0
O IA 192.168.34.0/24 [110/20] via 192.168.45.4, 01:15:58, Ethernet0/1
O IA 192.168.48.0/24 [110/20] via 192.168.45.4, 00:58:17, Ethernet0/1
R5#show ip ospf 1 database

            OSPF Router with ID (5.5.5.5) (Process ID 1)

                Router Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum Link count
4.4.4.4         4.4.4.4         1687        0x80000005 0x005F6F 1
5.5.5.5         5.5.5.5         681         0x80000009 0x003626 2
6.6.6.6         6.6.6.6         574         0x80000007 0x00D4CE 1

                Net Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.45.5    5.5.5.5         1664        0x80000004 0x00A1C1
192.168.56.5    5.5.5.5         681         0x80000003 0x008EC2

                Summary Net Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.0    4.4.4.4         1165        0x80000008 0x00F998
192.168.23.0    4.4.4.4         1687        0x80000004 0x002471
192.168.28.0    4.4.4.4         1432        0x80000003 0x00EEA2
192.168.34.0    4.4.4.4         1687        0x80000004 0x00464E
192.168.48.0    4.4.4.4         1687        0x80000002 0x00AFD8

                Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
192.168.67.0    6.6.6.6         581         0x80000005 0x009542 0

Can we simplify the Route Table by Stub Area or Totally Stubby Area? The answer is NO because Area 20 is connected to External Network. But we can use Not So Stubby Area (NSSA). The command is area <area no> nssa

hostname R4
!
router ospf 1
 area 20 nssa
 network 192.168.34.0 0.0.0.255 area 0
 network 192.168.45.0 0.0.0.255 area 20
 network 192.168.48.0 0.0.0.255 area 0
hostname R5
!
router ospf 1
 area 20 nssa
 network 192.168.45.0 0.0.0.255 area 20
 network 192.168.56.0 0.0.0.255 area 20
hostname R6
!
router ospf 1
 area 20 nssa
 redistribute rip subnets
 network 192.168.56.0 0.0.0.255 area 20

What changes for OSPF Database on R5? Type 4 and Type 5 are killed and we have a new member Type 7.

R5#show ip ospf 1 database

            OSPF Router with ID (5.5.5.5) (Process ID 1)

                Router Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum Link count
4.4.4.4         4.4.4.4         159         0x80000008 0x0005BE 1
5.5.5.5         5.5.5.5         236         0x8000000C 0x00DF72 2
6.6.6.6         6.6.6.6         237         0x80000009 0x00801A 1

                Net Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.45.5    5.5.5.5         192         0x80000007 0x004119
192.168.56.6    6.6.6.6         236         0x80000001 0x00FF48

                Summary Net Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.0    4.4.4.4         267         0x80000009 0x009DED
192.168.23.0    4.4.4.4         158         0x80000006 0x00C5C7
192.168.28.0    4.4.4.4         267         0x80000004 0x0092F7
192.168.34.0    4.4.4.4         158         0x80000006 0x00E7A4
192.168.48.0    4.4.4.4         158         0x80000004 0x00512F

                Type-7 AS External Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum Tag
192.168.67.0    6.6.6.6         248         0x80000001 0x0068C1 0

NSSA blocks Type 4 and Type 5 but it uses Type 7 to pass External Network information. Type 7 is similar to Type 5. When the Type 7 reach R4 from R6, it will transform to Type 5 to enter the other Area.

R5#show ip ospf 1 database nssa-external

            OSPF Router with ID (5.5.5.5) (Process ID 1)

                Type-7 AS External Link States (Area 20)

  Routing Bit Set on this LSA
  LS age: 373
  Options: (No TOS-capability, Type 7/5 translation, DC)
  LS Type: AS External Link
  Link State ID: 192.168.67.0 (External Network Number )
  Advertising Router: 6.6.6.6
  LS Seq Number: 80000001
  Checksum: 0x68C1
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        TOS: 0
        Metric: 20
        Forward Address: 192.168.56.6
        External Route Tag: 0

The number of routes did not change on R5, it only change E2 to N2. But in terms of transmission of LSAs, NSSA reduce Type 4 and Type 5, replaced them by Type 7.

R5#show ip route | begin Gateway
Gateway of last resort is not set

O IA 192.168.12.0/24 [110/40] via 192.168.45.4, 00:12:50, Ethernet0/1
O IA 192.168.28.0/24 [110/30] via 192.168.45.4, 00:12:50, Ethernet0/1
C    192.168.45.0/24 is directly connected, Ethernet0/1
     5.0.0.0/32 is subnetted, 1 subnets
C       5.5.5.5 is directly connected, Loopback0
C    192.168.56.0/24 is directly connected, Ethernet0/0
O IA 192.168.23.0/24 [110/30] via 192.168.45.4, 00:12:50, Ethernet0/1
O N2 192.168.67.0/24 [110/20] via 192.168.56.6, 00:12:50, Ethernet0/0
O IA 192.168.34.0/24 [110/20] via 192.168.45.4, 00:12:50, Ethernet0/1
O IA 192.168.48.0/24 [110/20] via 192.168.45.4, 00:12:50, Ethernet0/1

Then, we can try Totally Not So Stubby Area add a keyword no-summary after nssa.

hostname R4
!
router ospf 1
 area 20 nssa no-summary
 network 192.168.34.0 0.0.0.255 area 0
 network 192.168.45.0 0.0.0.255 area 20
 network 192.168.48.0 0.0.0.255 area 0
hostname R5
!
router ospf 1
 area 20 nssa no-summary
 network 192.168.45.0 0.0.0.255 area 20
 network 192.168.56.0 0.0.0.255 area 20
hostname R6
!
router ospf 1
 area 20 nssa no-summary
 redistribute rip subnets
 network 192.168.56.0 0.0.0.255 area 20

You may already guess the result. Yes! All Type 3 are killed and replaced by 0.0.0.0.

R5#show ip ospf 1 database

            OSPF Router with ID (5.5.5.5) (Process ID 1)

                Router Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum Link count
4.4.4.4         4.4.4.4         1034        0x80000008 0x0005BE 1
5.5.5.5         5.5.5.5         1111        0x8000000C 0x00DF72 2
6.6.6.6         6.6.6.6         1112        0x80000009 0x00801A 1

                Net Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.45.5    5.5.5.5         1068        0x80000007 0x004119
192.168.56.6    6.6.6.6         1112        0x80000001 0x00FF48

                Summary Net Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum
0.0.0.0         4.4.4.4         108         0x80000001 0x00C065

                Type-7 AS External Link States (Area 20)

Link ID         ADV Router      Age         Seq#       Checksum Tag
192.168.67.0    6.6.6.6         1119        0x80000001 0x0068C1 0

Route Table is simplified.

R5#show ip route | begin Gateway
Gateway of last resort is 192.168.45.4 to network 0.0.0.0

C    192.168.45.0/24 is directly connected, Ethernet0/1
     5.0.0.0/32 is subnetted, 1 subnets
C       5.5.5.5 is directly connected, Loopback0
C    192.168.56.0/24 is directly connected, Ethernet0/0
O N2 192.168.67.0/24 [110/20] via 192.168.56.6, 00:03:07, Ethernet0/0
O*IA 0.0.0.0/0 [110/11] via 192.168.45.4, 00:03:07, Ethernet0/1

Metric and Cost

Cost is use to calculate metric. Metric is equal to the total cost from source to destination. The default value of Cost is 100Mbit / Interface Bandwidth. 100Mbit is so called Reference Bandwidth. Let us try to calculate the total cost from R1 to 3.3.3.3 network.

ospf

First, R1 use eth0/0 to reach R2. The bandwidth of eth0/0 is 10000Kbit (10Mbit). So, cost = 100M / 10M = 10

R1#show interfaces ether0/0 | include BW
  MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec,

Then R2 use serial1/0 to reach R3, cost = 100M / 1.544M = 64

R2#show interfaces serial 1/0 | include BW
  MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,

After reach R3, use Loopback 0 to reach the destination, cost = 100M / 8000M = 1 (The minimum value of cost is 1)

R3#show interfaces loopback 0 | include BW
  MTU 1514 bytes, BW 8000000 Kbit, DLY 5000 usec,

So, from R1 to 3.3.3.3, cost = 10 + 64 + 1 = 75. Check the answer in the Route Table at R1.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/11] via 192.168.12.2, 00:18:58, Ethernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/75] via 192.168.12.2, 00:18:58, Ethernet0/0
O    192.168.23.0/24 [110/74] via 192.168.12.2, 00:18:58, Ethernet0/0

Oppositely, it should be 75 also from R3 to R1.

R3#show ip route | begin Gateway
Gateway of last resort is not set

O    192.168.12.0/24 [110/74] via 192.168.23.2, 00:02:33, Serial0/0
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/75] via 192.168.23.2, 00:02:33, Serial0/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.168.23.2, 00:02:33, Serial0/0
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
C    192.168.23.0/24 is directly connected, Serial0/0

We have several methods to change the cost, includes change the ip ospf cost, change the interface bandwidth or change the reference bandwidth.

ip ospf cost

First, we can change the cost directly at the interface. For example, change the cost of eth0/0 at R1 to 50. And the metric becomes 115 (50 + 64 + 1 = 115).

R1(config)#int ethernet 0/0
R1(config-if)#ip ospf cost 50
R1(config-if)#end
R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/51] via 192.168.12.2, 00:00:08, Ethernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/115] via 192.168.12.2, 00:00:08, Ethernet0/0
O    192.168.23.0/24 [110/114] via 192.168.12.2, 00:00:08, Ethernet0/0

Important! The command only changes the cost of eth0/0 at R1. No changes at the opposite side. Check Route Table on R3. The metric did not change.

R3#show ip route | begin Gateway
Gateway of last resort is not set

O    192.168.12.0/24 [110/74] via 192.168.23.2, 00:02:57, Serial0/0
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/75] via 192.168.23.2, 00:02:58, Serial0/0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.168.23.2, 00:02:58, Serial0/0
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
C    192.168.23.0/24 is directly connected, Serial0/0

Interface Bandwidth

Since cost = 100Mbit / Interface Bandwidth, we can change the Interface Bandwidth in order to change the cost. For example, we want to change the cost of E0/0 of R1 to 20. Just change the Interface Bandwidth to 5Mbit and the metric will become 85 (20 + 64 + 1 = 85). Change the bandwidth only change the cost calculation of Routing Protocol but not the actual transmit bandwidth.

R1(config)#int ethernet 0/0
R1(config-if)#bandwidth ?
  <1-10000000>  Bandwidth in kilobits
  inherit       Specify that bandwidth is inherited
  receive       Specify receive-side bandwidth

R1(config-if)#bandwidth 5000
R1(config-if)#end
R1#
R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/21] via 192.168.12.2, 00:00:13, Ethernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/85] via 192.168.12.2, 00:00:13, Ethernet0/0
O    192.168.23.0/24 [110/84] via 192.168.12.2, 00:00:13, Ethernet0/0

reference bandwidth

At last, we can try to change Reference Bandwidth. Change the Reference Bandwidth to 1000. Since the cost of eth0/0 at R1 become 1000 / 10 = 100 and the total cost becomes 165 (100+64+1). Although it is not a must, reference bandwidth should be changed on all OSPF routers to make sure the cost is same when having same bandwidth in different interfaces.

R1(config)#router ospf 1
R1(config-router)#auto-cost reference-bandwidth 1000
R1(config-router)#end
R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/101] via 192.168.12.2, 00:01:46, Ethernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/165] via 192.168.12.2, 00:01:46, Ethernet0/0
O    192.168.23.0/24 [110/164] via 192.168.12.2, 00:01:46, Ethernet0/0

If you have interfaces that the bandwidth is larger than 100M, please increase the Reference Bandwidth. Because the default value 100 will make all 10G, 1G and 100M Interface have the cost 1 (minimum value). In this situation, OSPF cannot compare the link cost.

External Route Cost

Do you remember that there are two types of External Route, E1 and E2. We will explain the difference now.

ospf

First, set the External Route Type to E1 and set the Metric to 99.

hostname R2
!
router eigrp 100
 network 192.168.23.0
 no auto-summary
!
router ospf 1
 redistribute eigrp 100 metric-type 1 metric 99
 network 192.168.12.0 0.0.0.255 area 0

Check Route Table on R1, the External Route is mark as E1, and Metric is 109. 109 is sum of 10 from R1 to R2 and the redistribute metric 99.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O E1 192.168.23.0/24 [110/109] via 192.168.12.2, 00:00:10, Ethernet0/0

How about if we use Metric Type 2?

hostname R2
!
router eigrp 100
 network 192.168.23.0
 no auto-summary
!
router ospf 1
 redistribute eigrp 100 metric-type 2 metric 99
 network 192.168.12.0 0.0.0.255 area 0

It is found that E2 only use Metric 99 to be the cost. The different is E2 does not add the OSPF Router Cost but E1 does. E2 is the default value if metric type is not defined when using redistribution.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O E2 192.168.23.0/24 [110/99] via 192.168.12.2, 00:00:18, Ethernet0/0

Path Selection

As like as other Routing Protocol, OSPF do not put all routes in the Route Table. Instead, it chooses the best path. How do OSPF choose the best path? If OSPF found that there are more than one paths to reach the destination, best path will be decided by the following order.

  1. By Route Type, Intra-area (O) > Inter-area (O IA) > Type 1 Exteranl (O E1 / N1) > Type 2 External (O E2 / N2)
  2. For same Route Type, compare the Metric. Smaller wins.
  3. For same Metric, add n paths to the Route Table to have load balancing (while n = maximum-paths parameters)

Route Type

Do the following labs to prove it.

ospf

There are four routes for R1 to reach 6.6.6.6 with same Metric,

  1. Intra-area Route (O) through R5
  2. Inter-area Route (O IA) through R4
  3. E1 External Route (O E1) through R3
  4. E2 External Route (O E2) through R2

Router configuration,

hostname R1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.13.1 255.255.255.0
!
interface Ethernet0/2
 ip address 192.168.14.1 255.255.255.0
!
interface Ethernet0/3
 ip address 192.168.15.1 255.255.255.0
!
router ospf 1
 network 192.168.12.0 0.0.0.255 area 0
 network 192.168.13.0 0.0.0.255 area 0
 network 192.168.14.0 0.0.0.255 area 0
 network 192.168.15.0 0.0.0.255 area 10
hostname R2
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.26.2 255.255.255.0
!
router eigrp 100
 network 192.168.26.0
 no auto-summary
!
router ospf 1
 redistribute eigrp 100 metric 21 subnets
 network 192.168.12.0 0.0.0.255 area 0
hostname R3
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.13.3 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.36.3 255.255.255.0
!
router eigrp 200
 network 192.168.36.0
 no auto-summary
!
router ospf 1
 redistribute eigrp 200 metric 11 metric-type 1 subnets
 network 192.168.13.0 0.0.0.255 area 0
hostname R4
!
interface Loopback0
 ip address 4.4.4.4 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.14.4 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.46.4 255.255.255.0
!
router ospf 1
 network 192.168.14.0 0.0.0.255 area 0
 network 192.168.46.0 0.0.0.255 area 10
hostname R5
!
interface Loopback0
 ip address 5.5.5.5 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.15.5 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.56.5 255.255.255.0
!
router ospf 1
 network 192.168.15.0 0.0.0.255 area 10
 network 192.168.56.0 0.0.0.255 area 10
hostname R6
!
interface Loopback0
 ip address 6.6.6.6 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.26.6 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.36.6 255.255.255.0
!
interface Ethernet0/2
 ip address 192.168.46.6 255.255.255.0
 half-duplex
!
interface Ethernet0/3
 ip address 192.168.56.6 255.255.255.0
!
router eigrp 100
 network 6.6.6.6 0.0.0.0
 network 192.168.26.0
 no auto-summary
!
router eigrp 200
 network 6.6.6.6 0.0.0.0
 network 192.168.36.0
 no auto-summary
!
router ospf 1
 network 6.6.6.6 0.0.0.0 area 10
 network 192.168.46.0 0.0.0.255 area 10
 network 192.168.56.0 0.0.0.255 area 10

First, shutdown eth0/1, eth0/2, eth0/3 at R1. Then, R1 use the E2 path, Next Hop R2 (192.168.12.2) to reach 6.6.6.6.

R1(config)#interface range ethernet 0/1 - 3
R1(config-if-range)#shutdown
R1(config-if-range)#end
R1#
R1#show ip route | include 6.6.6.6
O E2    6.6.6.6 [110/21] via 192.168.12.2, 00:14:35, Ethernet0/0

No shutdown the eth0/1, since the Next Hop R3 (192.168.13.3) Route is E1, OSPF think that E1 is better than E2. So, it choose E1 to use in  the Route Table instead of E2.

R1(config)#interface ethernet 0/1
R1(config-if)#no shutdown
R1(config-if)#end
R1
R1#show ip route | include 6.6.6.6
O E1    6.6.6.6 [110/21] via 192.168.13.3, 00:00:46, Ethernet0/1

Then, no shutdown the eth0/2, and Next Hop R4 (192.168.14.4) is O IA Route which is better than E1. OSPF choose this route now.

R1(config)#interface ethernet 0/2
R1(config-if)#no shutdown
R1(config-if)#end
R1#
R1#show ip route | include 6.6.6.6
O IA    6.6.6.6 [110/21] via 192.168.14.4, 00:00:05, Ethernet0/2

At last, no shutdown the eth0/3. Of course, R1 choose the Next Hop R5 (192.168.15.5) because Intra-area route is the best.

R1(config)#interface ethernet 0/3
R1(config-if)#no shutdown
R1(config-if)#end
R1#
R1#show ip route | include 6.6.6.6
O       6.6.6.6 [110/21] via 192.168.15.5, 00:00:00, Ethernet0/3

Metric

If the Route Type is same, OSPF choose smaller Metric route into the Route Table. Use the following topology, put all interfaces into same Area so that all routes will be Intra-area Route. Change the cost of interfaces at R1 and then check the Route Table.

ospf

At this moment, the metric of R2 path is 30 + 10 + 1 = 41, the metric of R3 path is 20 + 10 + 1 = 31, and that of R4 is 10 + 10 + 1 = 21. R4 path is chosen because of the smallest metric.

R1(config)#interface ethernet 0/0
R1(config-if)#ip ospf cost 30
R1(config-if)#interface ethernet 0/1
R1(config-if)#ip ospf cost 20
R1(config-if)#interface ethernet 0/2
R1(config-if)#ip ospf cost 10
R1
R1#show ip route | include 5.5.5.5
O       5.5.5.5 [110/21] via 192.168.14.4, 00:00:03, Ethernet0/2

Load Balancing

If best path cannot be decided by Route Type and Metric, OSPF will put 4 routes into Route Table by default to have Load Balancing on these paths. By using the above topology again, if all of the interface cost of R1 are the same, all three routes will be added to Route Table.

R1#show ip ospf interface ethernet 0/0 | include Cost
  Process ID 1, Router ID 192.168.114.1, Network Type BROADCAST, Cost: 10
R1#show ip ospf interface ethernet 0/1 | include Cost
  Process ID 1, Router ID 192.168.114.1, Network Type BROADCAST, Cost: 10
R1#show ip ospf interface ethernet 0/2 | include Cost
  Process ID 1, Router ID 192.168.114.1, Network Type BROADCAST, Cost: 10
R1
R1#show ip route | begin 5.5.5.5
O       5.5.5.5 [110/21] via 192.168.14.4, 00:00:54, Ethernet0/2
                [110/21] via 192.168.13.3, 00:00:54, Ethernet0/1
                [110/21] via 192.168.12.2, 00:00:54, Ethernet0/0
O    192.168.35.0/24 [110/20] via 192.168.13.3, 00:00:54, Ethernet0/1

The default is four but we can change it by using maximum-paths <no of path> to set from 1 to 16 routes of Load Balance. For instance, change maximum-paths of R1 to 2, Route Table only has 2 Load Balance Routes now.

R1(config)#router ospf 1
R1(config-router)#maximum-paths ?
  <1-16>  Number of paths

R1(config-router)#maximum-paths 2
R1(config-router)#end
R1#
R1#show ip route | begin 5.5.5.5
O       5.5.5.5 [110/21] via 192.168.13.3, 00:00:13, Ethernet0/1
                [110/21] via 192.168.12.2, 00:00:13, Ethernet0/0
O    192.168.35.0/24 [110/20] via 192.168.13.3, 00:00:13, Ethernet0/1

Or you can try to change it to 1. However, I cannot find any articles on Internet to describe that how OSPF choose the route......By random of what? If you know ,please comment.

R1(config)#router ospf 1
R1(config-router)#maximum-paths 1
R1(config-router)#end
R1#
R1#show ip route | begin 5.5.5.5
O       5.5.5.5 [110/21] via 192.168.12.2, 00:00:03, Ethernet0/0
O    192.168.35.0/24 [110/20] via 192.168.13.3, 00:00:03, Ethernet0/1

Virtual Link

Virtual Link can merge two Areas. We can use it for 2 situations.

  1. Build a Virtual Link to connect Area to Backbone Area 0 while there are no physical connection.
  2. Build a Virtual Link to merge Area 0 while they are not connected

Connect to Area 0

As we said at the very begining, all Area must connect to Backbone Area 0.

ospf

In the above topology, Area 20 is not connected to Area 0. Even the configuration of OSPF is done, R1 and R2 did not received Area 20 routes.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/20] via 192.168.12.2, 00:15:19, Ethernet0/0
R2#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/1
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
C    192.168.23.0/24 is directly connected, Ethernet0/0

Use area <transit area> virtual-link <router-id> command to connect R2 and R3 by using virtual link. Transit area is the Area that Virtual Link going through, and router-id is the Router ID at the opposite side.

R2(config)#router ospf 1
R2(config-router)#area 10 virtual-link 3.3.3.3
R3(config)#router ospf 1
R3(config-router)#area 10 virtual-link 2.2.2.2

Both R1 and R2 received route of Area 20 after the Virtual Link is configured.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/20] via 192.168.12.2, 00:01:06, Ethernet0/0
O IA 192.168.34.0/24 [110/30] via 192.168.12.2, 00:01:06, Ethernet0/0
R2#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/1
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
C    192.168.23.0/24 is directly connected, Ethernet0/0
O IA 192.168.34.0/24 [110/20] via 192.168.23.3, 00:01:40, Ethernet0/0

Connect two Area 0

Only one Backbone Area 0 is allowed in the whole OSPF. If there are two Area 0, they must be connected by Virtual Link.

ospf

In the above setting, the two Area 0 cannot be connected if no Virtual Link is configured.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/20] via 192.168.12.2, 00:03:36, Ethernet0/0
R4#show ip route | begin Gateway
Gateway of last resort is not set

     4.0.0.0/32 is subnetted, 1 subnets
C       4.4.4.4 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/20] via 192.168.34.3, 00:03:45, Ethernet0/1
C    192.168.34.0/24 is directly connected, Ethernet0/1

So, we need to establish a Virtual Link between R2 and R3.

R2(config)#router ospf 1
R2(config-router)#area 10 virtual-link 3.3.3.3
R3(config)#router ospf 1
R3(config-router)#area 10 virtual-link 2.2.2.2

The two Area 0 are connected. Although there is an Area 10 between the two Area 0, the route is an Intra-area Route.

R1#show ip route | begin Gateway
Gateway of last resort is not set

C    192.168.12.0/24 is directly connected, Ethernet0/0
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/20] via 192.168.12.2, 00:00:54, Ethernet0/0
O    192.168.34.0/24 [110/30] via 192.168.12.2, 00:00:54, Ethernet0/0
R4#show ip route | begin Gateway
Gateway of last resort is not set

O    192.168.12.0/24 [110/30] via 192.168.34.3, 00:01:09, Ethernet0/1
     4.0.0.0/32 is subnetted, 1 subnets
C       4.4.4.4 is directly connected, Loopback0
O IA 192.168.23.0/24 [110/20] via 192.168.34.3, 00:01:09, Ethernet0/1
C    192.168.34.0/24 is directly connected, Ethernet0/1

Coming Soon.....

Summarization