OSPF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

www.itworldcentral.

com/networks/ospf

Open Shortest Path First


PROPERTIES OF OSPF
 OSPF was developed by IETF (Internet Engineering Task Force)
 It was developed as a replacement for RIP, which was quiet problematic not
flexible and not scalable.
 It is an Interior Gateway Routing Protocol (IGP)
 It uses Dijkstra’s SPF (Shortest Path First) algorithm which is open (not proprietary
to any vendor)
 It’s a Link State Routing Protocol, it send triggered and incremental updates
 OSPF is fully classless routing protocol and it supports classless routing table
lookups, VLSM and supernetting.
 It supports Equal-Cost load balancing, so you can efficiently use multiple paths
 OSPF’s metric is link cost and it depends upon the bandwidth on the link
Formula to calculate Link Cost
Cost = 108 / bandwidth
 OSPF uses reserved multicast addresses to reduce the impact on non-OSPF-
Speaking devices in Network.
 OSPF supports authentication for more secure routing
 OSPF uses route tagging feature for external routes for tracking purpose
 Main advantages of using OSPF in your network is faster convergence, it’s
scalability to much larger scale, and less sensitivity to bad routing information
 OSPF have concept of areas, which reduces its impact on CPU and memory
 Different areas communicate with each other through area 0, area 0 is also known
as backbone area.

Each network you advertise, you’ll have to put it into an area and the area number
can be from 0 to 4294967295

Different areas in OSPF communicate with each other through area 0, areas
cannot communicate with each other until and unless area 0 is in between them,
area 0 can communicate with all areas

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Area is a collection of routers and other networking devices.

 You can run multiple instances of OSPF at the same time on a router and every
OSPF instance have an identification number and it can be from 1 to 65535
 Route Summarization is performed by ABR (Area Border Router)
 OSPF is IETF recommended IGP (Interior Gateway Routing Protocol) and is most
widely used IGP in the world
 OSPF also have capacity to support Type of Service (TOS) routing

Communication between different areas


All the areas can communicate with only area 0 or within their own area domain, if they
want to communicate with another area, area 0 should be between them, let’s have a
look

Condition 1

Area 0 is communicating with Area 1, but Area 2 cannot communicate with Area 1 and
Area 0

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Condition 2

In this case only Area 2 is communicating with Area 0, and Area 1 cannot communicate
with Area 2 and Area 0.

Condition 3

In this case you can see all the areas are communicating with each other, Area 0 is in
between so Area 1 and 2 can communicate with each other and both of them can
communicate with area 0.

 Sends Hello packets on chosen interfaces on which OSPF is running

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Hello messages are sent after every 10 seconds on broadcast / Point to


point networks and every 30 seconds on NBMA (Non Broadcast Multiple
Access) network like frame relay

OSPF Hello Packet Contents


Router ID Neighbors *

Hello & Dead Timers * Router Priority


Network Mask * DR/BDR IP Address
Area ID * Authentication Password *

[table id=5 /]

Types of OSPF Implementation


There are two types of OSPF Implementations

1. Single area OSPF


2. Multiple area OSPF

Single area OSPF


Network domain where all the OSPF running routers are configured in the same
area is single area OSPF

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Multiple area OSPF


Network domain where different OSPF running routers are configured in the
different area is multiple area OSPF

Types of tables in OSPF


OSPF make three types of tables
1. Neighbor table
2. Topology table
3. Routing table

Neighbor Table
Maintains information about all of its neighbors, every router will have its own
neighbor table and it will be different for every router.

Topology Table
Topology table contains all possible paths to a destination. It is the picture of the
network and topology table of all the devices in a network will be same.

Routing Table
It contains the best path to a destination.

Inverse mask
OSPF uses inverse mask or Wild Card Mask instead of Subnet Mask (used by RIP),
some people define it as opposite to Subnet mask for example.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Subnet Mask Inverse Mask

255.255.255.0 0.0.0.225

255.255.255.224 0.0.0.31

225.255.255.255 0.0.0.0

 Wild card mask is used in OSPF and access lists, OSPF wild card mask should
be continuous.

For more details about Inverse mask kindly click here

Convergence
A state in which all the routers in the network knows about all networks in the topology,
the basic goal of routing is to perform convergence.

You can perform convergence by:

Static Routing
By static routes

Dynamic routing
Dynamically with the help of routing protocols

Router ID
Each OSPF running router uses a router ID, a Router ID is a 32 bit number assigned to
each router running OSPF to uniquely identify a router within an autonomous system.

Selection of router ID
An OSPF running router chooses the Router ID in following sequence

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Highest IP address of any logical (virtual) interface


OSPF automatically chooses highest IP address on any logical or virtual interface
on the router, even if physical interface have got the highest interface it will go for
highest IP address on logical interface.

Highest IP address on Physical interface,


Incase if there’s no logical interface on the router, in that case OSPF will choose
the highest IP address on any of your physical interface as Router ID for OSPF.

Hard coated Router ID


You can configure your Router ID by yourself
If you want to configure it by yourself you’ll have to configure it within 40 seconds
of starting OSPF or otherwise it will choose its Router ID by itself.

Never use IP address of the physical interface as your Router ID, as there are
possibilities for physical interface to go down, it can malfunction or it can go
down because of any problem, always hard coat IP address from a virtual
interface as your OSPF Router ID.

Once Router ID is configured it cannot be changed until the router is rebooted


or DR/BDR are re-elected.

Autonomous system
A network with the same routing policies is called autonomous system.
 In an autonomous system you can have multiple areas
 In one area you can have multiple networks
 Every network have its own DR and BDR, if it’s a multi-access network (Ethernet)

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

OSPF Elections
 Elections occur in a multi-access network, one network can have only one DR and
only one BDR, the remaining routers will become DR others
 Election in OSPF is stable one election is finalized it will never change, if they
change then it means that our databases will keep on changing

The Election of DR and BDR depends upon two factors


 Router ID
 Priority

By Default in OSPF all the routers have same priority i.e. 1 and it’s tune-able.
The router with highest priority wins the election and the router with second highest
Priority will become BDR all others becomes DR Others.

DR – BDR Election
First of all Router Priority will be checked, Router with highest priority wins election and
the one with second highest priority becomes BDR.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

If priority is same
If the Priority is same in that case router with highest Router ID will become DR and one
with second highest Router ID will become BDR.

Now if another router with higher Priority or Router ID joins the network, it will not affect
the Network or OSPF elections, OSPF elections are stable, as stability is very serious
requirement for networks.

Always make a good configuration and stable router DR or BDR in your Network

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

DEFINING DR AND BDR IN YOUR NETWORK


 You must complete your OSPF configuration within 40 Seconds, only than
elections will be on fair basis.
 You can clear ospf process in order to organize OSPF elections once again.

It is highly recommended not to use “clear ip ospf” process in live network, as it


will give you down time.

 If DR goes down BDR will get promoted to DR and the router with third highest
priority will take pace of BDR

 If new elected DR also goes down, new BDR will be promoted to BDR and
elections will take place for new BDR, and the rest will remain as DR others

 If old DR comes back again, it will not affect the OSPFprocess, OSPF elections
are very stable and re-elect process will not start again until and unless router
reboots or you use clear ip ospf command

Role of DR and BDR


If there are 100’s of routers in the network and every single router starts sending updates
to all other routers in the network, it will eat up resources so DR and BDR handles the
convergence.
 Every network have its own DR and BDR, provided if it’s a multi-access network.
 Routers instead of broadcasting, they multicast the network updates to DR and
BDR.
 The very first process in OSPF is DR and BDR election, because DR and BDR are
responsible for communication, to manage the database of LSA it’s another
responsibility of DR and BDR
To ensure you can debug RIP packets and you will see RIP sends it’s packets to
255.255.255.255 and after that if you debug OSPF packets you will see it
multicasts on two addresses
1. 224.0.0.5
2. 224.0.0.6

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

How many DR and BDR are there in these topologies?

Topology 1

Topology 2

Topology 3

Router# show ip ospf interface

To check what interfaces are participating in OSPF process.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

 A router is DR / BDR / DR other at interface level not as a whole.


 A router can be DR / BDR / DR Other at the same time at different interfaces.

Practice Lab

I. Configure that router with lowest priority first so that it can become DR
II. Now configure that router second priority so that it can become BDR
III. And now configure the highest priority router to become DR other
IV. Clear OSPF process to see the fair elections result

Types of Routers in OSPF


Internal router
Router with all interfaces in the same area is known as internal router

Backbone Router/ Backbone Internal Router


Router’s whose all interfaces are in the same area and that area is backbone area.

Area Border Router


Router which provides connectivity between two areas and make possible for them to
communicate with each other.

Autonomous System Boundary Router


Router which provides connectivity between two autonomous systems and make
possible for them to communicate with each other.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

 A router can have DR, BDR, IR, BIR, ABR and ASBR, all these states at same
time.

Convergence in OSPF
There are three steps involved in convergence
1. Neighbor table
2. Topology Table
3. Routing Table

Neighbor Table
Neighbor table is made when OSPF process is started and routers send LSAs to their
directly connected neighbors. Neighbor table is different on each and every router; it
contains details of directly connected neighbors

Topology Table
Database table also known as topology table, it contains all possible paths for
reaching a destination. It contains details about all the devices, it contains complete
picture of network, and database table is same on all routers
We’re living in the same city, so if we buy map for our city everybody will have the
same map.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Routing Table
After algorithm is applied on database table to find the best path to a destination (Every
routing protocol have its own algorithm OSPF uses dijkstra algorithm, It is also
different on each router.

It is not possible for a router to make topology table without making neighbor
table, similarly it’s not possible for router to make routing table without making
topology table so these are sequential steps

Types of Link State Advertisement


1. LSA 1 (Router LSA)
2. LSA 2 (Network LSA)
3. LSA 3 (Summary LSA)
4. LSA 4 (Summary LSA)
5. LSA 5 (External LSA)
6. LSA 6
7. LSA 7 (For NSSA)

Link System Advertisement Type 1


When any router comes up, or its interface goes down it advertises its link state; this
advertisement is called LSA 1.
Router multicasts its information (all entries) to DR, medium is broadcast and the
address is multicast.
Now this is DR responsibilities to tell every router that these new entries have
emerged update it into your database.

Link System Advertisement Type 2


After a router has reported its link state to DR, what DR multicasts to all other devices is
LSA 2.
Originator is present in every packet; it reads like, this packet is generated by
[router-id]

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Link System Advertisement Type 3 & 4


They are also called summary LSA; anything that is originated by ABR is called summary
LSA or LSA 3 and 4.
Difference between LSA 3 & 4 is LSA 3 shows the network information whereas
LSA 4 shows the location of ASBR (Tells IP address of ASBR as gateway).

Link System Advertisement Type 5


Also known as External LSA, it is anything originated by ASBR, from one area to another
area only summary is sent not all the information is sent.

We made areas to reduce the LSA traffic, if LSA are also sent across the areas then what
is the benefit of areas? In-fact the LSA within an area are fully detailed LSA and that
which are sent across the area are just summary LSA.

OSPF States
There are seven states of OSPF
I. Down
II. Init (One way state)
III. Two way state
IV. ExStart
V. Exchange
VI. Loading
VII. Full

DOWN
Router R1 sends Hello packet to router R2, if fields in hello packet do not matches with
R2, R1 will go in down state.

After 10 seconds Router A will send another Hello packet and will be in INIT state
and once again packet miss match will occur hence going once again to down
state and it’ll be stuck between these two states

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Init State
R1 have sent hello packet to R2 and its fields are matched, now R1 is waiting for R2 to
respond this state is called Init State.

Two way state


Router R1’s packet has been matched on B and Acknowledgement is sent to R1, also
R2’s Packet is matched on R1 and acknowledgement is sent to R2 this state is called two
way state.
Neighbor table is completed in two way state and it is also decided who is DR who is BDR

DR and BDR elections takes place after two way state before Exstart state and DR and
BDR are finalized.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

ExStart State
At this stage the Master and slave are declared, this decision is made to start the
communication, master starts the communication first, means it will send its link state
database first.

 Master and slave election is independent from DR and BDR elections, DR


responsibility is to manage the database of network and Master is responsible
for initializing the communication

Master and Slave Election


Master and slave are determined based on
1. Router Priority
2. Router ID (Breaks the Tie)

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Exchange State:
 DBD (Database Description Packets) and LSR (Link State Request Packets) are
exchanged in this state
 Master sends DBD’S (Database Description) first DBD’S are just summary for all the
routes
 First Master sends the DBD (summary for all the routes) to slave, Slave compares that
DBD with its database
 If there’s something missing slave sends LSR (link state request) “Hey buddy, please
send me details about 5.0.0.0 I don’t know about this network”

Loading State:
Slave in turn sends LSU (Link state update) to the master with Next hop, Cost, Metric,
Master starts loading these details into its memory, and is in loading state.
After that same process is repeated, but this time slave sends DBD and Master Checks.

EXCHANGE AND LOADING


1. Master send DBD to Slave
2. Master receives and compare DBD to its table and if something is missing sends
LSR to master.
3. Master reads LSR and sends the information about the routes slave have
requested.
4. Slave receives LSU and note down information about routes in his table (Loading).
5. Slave sends LsAck back to master

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

How many LSA’s are in one LSU depends upon LSR, Let suppose if 10 networks were
missing from R2 database, R2 will send LSR for 10 networks, so R1 instead of sending
10 LSA’s send one LSU containing 10 LSA’s

LSU is container of LSA’s

Full State
After all these DBD, LSR, LSU and LsAck (comparison of database) is completed and all
the networks are loaded into memory i.e. database table, this state is called full state.
Now we can run SPF algorithm to get the best path for our routing table.

Virtual links
When we’re talking about a link it should always be in between at-least two devices, to
be more specific when we talk about a virtual link it’s obvious that it requires atleast two
or more devices.

A virtual link is a link from any area which is not directly connected to area 0 to backbone
area (area 0) through a non-backbone area.

A virtual link is used for


 To link an area (which is not directly connected to area 0) to backbone area through
a non-backbone area.
 To connect two parts of a partitioned backbone area, two backbone areas which
are not directly connected.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

You cannot make a virtual link from any device to any other device, there are certain
conditions both deices should meet in order to make a virtual link.

Conditions for making a virtual link


 One of two devices must be part of area 0
 Both devices should have one area in common

In the above topology, which router have which area can be seen in the table below

Router Areas
R1 A0
R2 A0, A1
R3 A1, A2
R4 A2

Only on those routers who meets both the requirements, we can make a virtual link

Between 1st condition 2nd condition


Routers Area 0 Common area

R2 – R3  

R2 – R4  X

So Virtual link can be made between R2 and R3 only, Between R2 and R4 they don’t
meet both the requirements.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

Types of Areas in OSPF


There are three area types in OSPF
1. Stub area
2. Totally stub area
3. Not so stubby area

Stub area
A stub area is an area which does not receive route advertisements external to the
Autonomous system (AS) and routing from within the area is based entirely on a default
route.
Areas through which or into which AS external advertisements are not flooded.
An area where LSA 5 have got nothing to do, you can see LSA 1, 2, 3 and 4 but you won’t
see LSA 5 in stub area.

 ABR Blocks LSA 5 and inject a default static route 0.0.0.0, Replacing LSA 5 with
default static route.
 You might want to create stub areas when much of the topological database
consists of AS external advertisements
 This reduces the size of the routing databases (topological databases) for the
area's internal routers hence reducing the amount of memory required on the
internal routers in the stub area
Before creating stub you can see O, O IA, OE1 and OE2 in your table and after creating
stub you’ll see only O, O IA and O*IA 0.0.0.0, means replacing LSA 5 with O*IA 0.0.0.0

When an area border router is configured for a stub area, the router automatically
injects a default route instead of flooding area with external routes, so that
routers in the stub area can reach destinations outside the area.

 An area is stub, not the router, and you need to give “area xx stub” command to
all the routers in that area.
 When you configure an area as stub, it means that there’s only one exit point,
single exit point.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

 Stub areas are made, where we want to reduce the size of routing table, where
there is trusted network, our own network.
Like in route summarization, size of routing table is reduced in stub area also but
it’s a security loophole because now our traffic is going for unwanted destinations
(Networks) also.

Before we have full detailed routing table like 172.16.10.0, 172.16.20.0,


172.16.30.0 but now we have summary route like 172.16.0.0, so now traffic can
go from 172.16.1.0 to 172.16.255.0, so it’s a security threat, it’s open invitation go
anywhere.

 When you make a stub area it’s not right to say that you don’t have connection to
the outside world, you have connection but LSA from outside are not coming in
and you’re using default static route to go out of your network.

Not every area can be a stub area, there are several conditions where we cannot
make a stub area

 Backbone area cannot be a stub area


 Area in which we create a virtual link cannot be a stub area

 Backbone can never have single exit point, which is very much logical, backbone
is where the whole world connects.

Many people make a mistake, to make an area stub they go to ABR and give
command to make area stub, which is wrong, to make an area stub you’ll have to
configure area as stub on all routers inside the area.

To make an area, stub area we’ll have to configure on all routers, configuring on
only ABR may give you results sometimes but this is not the right way, to have
stable and predictable result you should configure on all routers, LSA’s will
disappear from routing table and default route will be injected, in cases of
mistake mostly default route is not injected

Totally Stub Area


In totally stub area LSA 3 and 4 are also blocked along with LSA 5, so you have only LSA
1 and LSA 2 in your area.

 Here in totally stub area you will see only routes with “O” and for “O IA” a default
route (0.0.0.0) will be injected.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

In Totally stub area we’ll see only LSA 1 and LSA 2 (Routes with “O”) means we
can see routes from our own area only where as in stub area we’ll see LSA 1, 2,
3 and LSA 4 which means we can see routes from our own Autonomous System.

LSA 5 is already filtered in stub area now in totally stub area LSA 3 and 4 (Summary LSA
– which is originated by ABR) are also filtered to enter your area so it’s not necessary to
go on all routers just go to ABR from where they are originating and give command of
totally stubby area.

It is sufficient to configure totally stubby area only on ABR, because LSA 3, 4 are
originated by ABR.

When we go back from totally stub area “no area 1 stub no-summary”, it goes
only one step back i.e. stub, we’ll have to give this command once again “no area
1 stub” then it will come out of stub.

Not so Stubby Area – NSSA


If you made an area stub then it will block LSA 5 without even checking its origin, not
necessarily LSA 5 will be generated by R1 only, it could be generated on R4 as well if we
advertise some routes on it.

If I make Area 1 NSSA area one will not suppress LSA produced by R1 but it will
suppress LSA 5 produced by R4 or any other ASBR.

As the name says NSSA is stub but very strictly.

www.itworldcentral.com
Connecting professional minds…
www.itworldcentral.com/networks/ospf

NSSA didn’t block LSA 5 of ASBR in its own area, even if there are 10 ASBR in
area but blocks LSA 5 of external ASBR’s, and covers LSA 5 of its own ASBR
with a covering of LSA 7.

After configuring Area 1 as stub area when R1 will generate LSA5 and advertise them
routers in Area 1 will see LSA5 arrived which is block, so to deal with this problem routers
in Area 1 covers LSA5 with another LSA cover which is LSA7 and when the border router
want to advertise it, it will open the covering of LSA7 and will advertise it as LSA5.

OSPF OPERATION
1. OSPF speaking router send hello packets out on OSPF enabled interfaces and if
both sides sharing a common data link agree on certain parameters specified in
their respective Hello packets, they become neighbors
2. Adjacencies which are like a point to point virtual link are formed between those
neighbors which have same attributes or values in hello packets.
3. All OSPF running routers sends LSA over their adjacencies, LSA’s explains all the
links of a router and their state along with neighbors, the link might be pointing to
Stub networks, to network in other areas, to another external network (maybe they
are advertised) or to a stub network.
4. On receiving LSA from neighbor every OSPF running router records LSA in its
Link-state Database and sends a copy of it to other neighbors.
5. By flooding LSA throughout area, all the routers will build identical link state
database.
6. All routers apply SPF algorithm on database to generate loop-free graph
describing shortest possible (with lowest cost) to every known destination or
network with itself as the root, this graph is known as SPF Tree.
7. Each router builds its own routing table from SPF tree.

www.itworldcentral.com
Connecting professional minds…

You might also like