13: OSPF Routing Protocol

OSPF (Open Shortest Path First) routing protocol is a link state routing protocol. Therefore, every router sends a network update once a change happens in the routes in its routing table. In addition, this network updates contain only the affected routes, and are sent to the entire network.

This allows every router to build a database that reflects the structure of the entire network. In addition, allow every router to have a faster convergence time than the distance vector routing protocols.

The convergence time is the time required to find an alternative path to a certain network, once its main path is unavailable.

OSPF characteristics

Image2238.JPG Figure 13.1

• It is a classless routing protocol. This means that it supports the CIDR, the VLSM and the disconiguous networks.

• The default cost of the path = ‘100M/BW’.

• It uses the ‘Dijkstra Shortest Path First (SPF)’ algorithm to determine the best path to every network.

• It logically segments the network into areas, as seen in figure (13.1).

• It uses ‘area 0’ (the backbone area) at the top of the hierarchy, this means that all other areas must be connected to ‘area 0’.

• It uses area numbers from the range (0: 65535).

13.1 OSPF neighbors and adjacencies in a LAN

Image2247.JPG Figure 13.2

• Routers send multicast ‘hello packets’ out of the OSPF interfaces to discover the OSPF neighbors.

• The hello packets are sent every time period called the ‘hello time’.

• If no hello packet is received from a certain router during a time period called the ‘dead time’, this router will be considered as unavailable.

• The hello packets are sent to a multicast IP address ‘’.

• The network administrator may configure the routers to authenticate each other before exchanging the routing updates.

• The following conditions must be met for the neighborship to be established between two routers,

  1. 1. The same hello/ dead timers.
  2. 2. The same subnet mask.
  3. 3. The same area ID.
  4. 4. The authentication type and PW.

• The routers that exist in the same area elect one router as a ‘DR’ (Designated Router), and another router as a ‘BDR’ (Backup Designated Router).

• All routers in the area establish an adjacency with the ‘DR’ and the ‘BDR’.

• All network updates are sent to the ‘DR’ and the ‘BDR’ on the IP address ‘’ using a ‘router LSA’ (Link State Advertisement).

• The ‘DR’ and the ‘BDR’ forward the network updates to the routers that exist in their area, this is done by sending a ‘network LSA’ on a multicast IP address ‘’.

13.2 OSPF configuration

To configure the OSPF routing on a router, we write the following commands,

Router(config)# router ospf process number

Router(config-router)# network network IP wildcard mask area area number

The Process Number is a locally significant number on every router.

The network IP is the destination network IP.

The wildcard mask is a reversed subnet mask. To get it, change every ‘1’ to ‘0’ and every ‘0’ to ‘1’ as seen in figure (13.3).

5756.jpgFigure 13.3: the wildcard mask

13.2.1 Passive interface configuration

Configuring an interface as a passive interface prevents it from sending or receiving the ‘hello packets’.

To configure an interface as a passive interface, we use the following command,

Router(config-router)# passive-interface interface

13.3 DR election

In the OSPF protocol, the routers in every area elect a ‘DR’ and a ‘BDR’.

When a router needs to send network updates to the other routers in the area, it sends this update to the ‘DR’ and the ‘BDR’. Then, the ‘DR’ and the ‘BDR’ forward this update to all the routers in the area.

How routers elect the ‘DR’?

  1. 1. First, choose the router with highest router priority.
  2. 2. If all the priorities are the same, choose the router with the highest ‘router ID’.

13.3.1 Router priority


The default router priority for every router is ‘1’.

The router priority can be changed manually using the following command,

Router(config-if)# ip ospf priority 2

13.3.2 Router ID (RID)

  1. 1. The ‘RID’ is statically assigned using the following command,

Router (config)# router ospf 0

Router(config-router)# router-id

  1. 2. If no statically assigned ‘RID’ exists, the ‘RID’ will be the highest loopback interface IP, the loopback interface is a virtual interface that can be configured on the router.

To configure a loopback interface, use the following commands,

Router(config)# interface loopback0

Router(config-if) ip address

  1. 3. If no loopback interface is configured on the router, the ‘RID’ will be the highest interface IP on the router.


Determine the ‘RID’ of the below router,



RID= the statically assigned RID =

If there wasn’t statically assigned RID,

RID = the highest loopback interface IP =

If there was not a loopback interface configured,

RID = the highest interface IP =