How to Work With OSPF Protocol

Introduction

In this article I am going to explain OSPF protocol in networking. OSPF is define as Open Shorted Path First Protocol. OSPF is a dynamic routing protocol that specifies how routers communicate with each other.

A Routing protocol is used to make communication between two or more routers. There are two types of routing for creating networks; they are:

  • Static routing
  • Dynamic routing 

Static Routing

Implementation of static routing is hard and complicated. In this type of routing we set all the routes manually and it is suitable for a small network.

Dynamic Routing

In dynamic routing protocol we use some routing protocol to set the route. There are two types of routing protocols; they are:

  • Interior gateway routing
  • Exterior gateway routing

Interior gateway routing

Interior gateway routing has two types of protocol; distance vector routing protocol and link state routing protocol.

OSPF (Open Shortest Path First)

OSPF is defined as Open Shorted Path First Protocol and is a dynamic routing protocol. OSPF is an example of the link state routing protocol. OSPF works on a large network because there is no limitation of the number of cops in the network.

OSPF supports classless routing, IPv4 and IPv6. OSPF divides the network into areas and creates a hieratical network. It does not share this complete routing table but shares only updates to other routers within the network.  OSPF uses 224.0.0.5 as the multicast address. Area 0 is known as the backbone area.

Types of router in OSPF:

  • Backbone Router
  • Internal Router
  • Area Border Router (ABR)
  • Autonomous system Border Router (ASBR)
  • Designated Router (DR)
  • Backup Designated Router (BDR)

Area Border Router (ABR)

A Router connected with two different areas is known as an area border router. Suppose one interface of a router connects with area 0 and another interface connects with area 1 then this type of router is known as an area border router. 

Autonomous System Border Router (ABR)

A Router connected with two different areas is known as an area border router. Suppose one interface of a router connects with area 0 and another interface connects with area 1 then this type of router is known as an area border router.

Designated Router

Selection of a designated router (DR) is based upon the priority of the router. The highest priority of all routers in the same area is selected as the designated router. If all or more than one router has the same priority then the router having the highest RID (Router ID) is selected as the DR.

Example

Here we are creating a network using the RIP protocol. In this network we have three routers, three switches and six PCs.

OspfRoutingProtocol.jpg

Configuration of Router 2

Router>enable
Router#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#host
Router(config)#hostname A
A(config)#interface fastEthernet 0/0
A(config-if)#ip address 192.168.1.1 255.255.255.0
A(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

A(config-if)#exit
A(config)#interface fastEthernet 0/1
A(config-if)#ip address 192.168.2.1 255.255.255.0
A(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Router(config)#router ospf 10
Router(config-router)#network 192.168.1.0 0.0.0.255 area 0

01:12:01: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.2.1 on FastEthernet0/1 from LOADING to FULL, Loading Done

Router(config-router)#network 192.168.2.0 0.0.0.255 area 0
01:14:25: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.5.1 on Ethernet1/0 from LOADING to FULL, Loading Done

Configuration of Router 3

Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address 192.168.2.2 255.255.255.0
Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up    
   
Router(config-if)#do ping 192.168.2.1
Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 3/4/7 ms
Router(config-if)#exit

Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.3.1 255.255.255.0
Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config-if)#exit
outer(config)#interface ethernet 1/0
Router(config-if)#ip address 192.168.4.1 255.255.255.0
Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface Ethernet1/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet1/0, changed state to up

Router(config-if)#exit

Router(config)#router ospf 10
Router(config-router)#network 192.168.2.0 0.0.0.255 area 0

01:12:01: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.2.1 on FastEthernet0/1 from LOADING to FULL, Loading Done

Router(config-router)#network 192.168.3.0 0.0.0.255 area 0
Router(config-router)#network 192.168.4.0 0.0.0.255 area 0
01:14:25: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.5.1 on Ethernet1/0 from LOADING to FULL, Loading Done

Configuration of Router 4

Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address 192.168.4.2 255.255.255.0
Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Router(config-if)#exit

Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.5.1 255.255.255.0
Router(config-if)#no shutdown

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit

Router(config)#router ospf 10
Router(config-router)#network 192.168.4.0 0.0.0.255 area 0

01:12:01: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.2.1 on FastEthernet0/1 from LOADING to FULL, Loading Done

Router(config-router)#network 192.168.5.0 0.0.0.255 area 0
01:14:25: %OSPF-5-ADJCHG: Process 10, Nbr 192.168.5.1 on Ethernet1/0 from LOADING to FULL, Loading Done

 

PC 1 communicated with PC 3

OspfRouting.jpg

PC 5 communicated with PC 0

RoutingProtocol.jpg

It shows route of router 2

ShowRoute.jpg

It shows route of router 3

DynamicRouting.jpg

It shows route of router 4 

Routing.jpg


Similar Articles