Networking

Cisco administration 101: What you need to know about OSPF

The Open Shortest Path First (OSPF) protocol is one of the most popular internal routing protocols used by midsize and large companies. Not very familiar with this protocol? David Davis tells you what every network administrator needs to know about OSPF in this edition of Cisco Routers and Switches.

Last year, I wrote an article that reviewed the basics of the Enhanced Interior Gateway Routing Protocol (EIGRP) ("Cisco administration 101: What you need to know about EIGRP"). As I mentioned in the article, EIGRP and Open Shortest Path First (OSPF) are the two most popular routing protocols for today's midsize and large companies—both offer a huge breadth of features that can cover just about any routing scenario such companies would need. That article answered some common questions about EIGRP, but what about OSPF?

Review the basics

OSPF is an internal routing protocol. (While primarily used inside a single company, it can span multiple sites.) Based on RFC 2328, it's an open standard. Because of this, OSPF is available on Microsoft's Windows Server 2003 OS, Linux, and many other network devices—unlike Cisco's EIGRP routing protocol. Like other dynamic routing protocols, OSPF enables routers to disclose their available routes to other routers.

OSPF is a link-state routing protocol that runs Dijkstra's algorithm to calculate the shortest path to other networks. Taking the bandwidth of the network links into account, it uses cost as its metric. OSPF works by developing adjacencies with its neighbors, periodically sending hello packets to neighbors, flooding changes to neighbors when a link's status changes, and sending "paranoia updates" to neighbors of all recent link state changes every 30 minutes.

While OSPF is an excellent routing protocol for networks of all sizes, one of its weaknesses is that it can be quite complex to configure. On the other hand, it offers more features than simpler protocols such as RIP.

Here are some of OSPF's strengths:

  • It converges quickly, compared to a distance-vector protocol.
  • Routing update packets are small, as it doesn't send the entire routing table.
  • It's not prone to routing loops.
  • It scales very well for large networks.
  • It recognizes the bandwidth of a link and takes this into account in link selection.
  • It supports variable-length subnet masks (VLSM) or Classless Inter-Domain Routing (CIDR).
  • It supports a long list of optional features that many others don't.

Configure OSPF

Some may find OSPF configuration intimidating, so let's look at how to make it easy. Let's start with a basic network: Our network example has two routers—one in San Diego (192.168.1.0 /24) and one in Dallas (192.168.2.0 /24). Between these two routers, there's a point-to-point T1 circuit with IP network address 1.1.1.0/30. The San Diego router's WAN interface is 1.1.1.1, and the Dallas router's WAN interface is 1.1.1.2.

We'll begin by configuring the router in San Diego. The first step to configuring OSPF is to use the router ospf command when in Global Configuration Mode. Here's an example:

Router(config)# router ospf {process number}
Router(config-router)#

While it doesn't matter which process number you use, I recommend keeping it the same on all OSPF routers on your network. I usually use 100 to keep everything simple. However, if you use different process numbers, OSPF will still work and exchange all routes—unlike EIGRP.

After entering OSPF Configuration Mode, the most common next step is to specify which networks OSPF will advertise, which you can do using the network command. Here's an example:

Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router(config-router)# network 1.1.1.0 0.0.0.3 area 0

The first parameter is the network ID, and the second parameter is the inverse mask. The inverse mask—or wildcard mask—is the inverse of the subnet mask. It tells OSPF what range of interfaces the IP addresses given will apply to. Therefore, you can have one network statement that covers multiple interfaces.

You also need to specify the area, which is how OSPF organizes networks. All traffic must flow through area 0. In a small network, it's logical to put all networks in area 0, as we did in the example.

After you've configured each side of the network, the routers will exchange routes and form adjacencies. You should see a statement in the log file or console that looks something like the following:

*Mar  1 02:53:33.370: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 
  on Ethernet0/0 from LOADING to FULL, Loading Done

To make sure you see these types of messages, use the log-adjacency-changes command in your OSPF router configuration. This command causes OSPF to enter information into the router's log file whenever it loses or regains connectivity with its neighbors. Here's an example:

Router(config-router)# log-adjacency-changes

Check the status of OSPF

After you've configured OSPF, you need to know how to check its status. Here are some common OSPF commands, along with links to their Cisco documentation and sample output from our example:

For more information on OSPF, see Cisco's OSPF Design Guide and Cisco's OSPF Documentation.

Miss a column?

Check out the Cisco Routers and Switches Archive, and catch up on David Davis' most recent columns.

Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!

David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.

13 comments

Thanks!

kasi_malla
kasi_malla

I need exact work and definition of administrative distance and what is autonomous system no, and can we give different autonomous nos to the routing protocols with in same network

J.D. Keith
J.D. Keith

It really is. A great article. But the fact that you include valuable content and break the matters down to basics is the best part. I really value this type of article so much more than the fluff types that many are publishing here. Thanks David!

HITLY2006
HITLY2006

the two WLAN interface's ip should also be refered, you konw , it's important for knowing route's link states from one router to another router

fday
fday

Your admin 101 columns are great! Keep them coming. I value the info on HappyRouter too!

wmlundine
wmlundine

I value these Cisco 101 discussions.

ddavis
ddavis

Thanks to everyone who posted your comments! I appreciate the feedback & appreciate you reading the TechRepublic Cisco Newsletter! -David

ddavis
ddavis

Hi fday! Thanks for your post! It is always great to hear that my articles are helpful! I'm also glad to hear that you have enjoyed my personal website, HappyRouter.com. Thanks for reading TechRepublic! -David

ivefallen
ivefallen

This is simple to understand, unlike what a Cisco press book can be. :0)

EEnglish34
EEnglish34

I always learn something new reading these articles. Thanks!

nabess
nabess

Terrific article with easy to understand information. Keep posting!

ddavis
ddavis

Thanks EEnglish & Wmlundine! Thanks for reading TechRepublic and taking time to post. I am glad that you found this article helpful! -David

Editor's Picks