Table of Contents
- What Is OSPF and Why It Replaced Older Protocols
- OSPF Fundamentals: Link-State and Dijkstra's Algorithm
- OSPF Areas and the Role of Area 0
- OSPF Neighbor Relationships and States
- Router ID Selection Process
- DR/BDR Election on Multi-Access Networks
- OSPF Cost Metric and Bandwidth
- Single-Area OSPF Configuration with Cisco IOS
- Useful Show and Debug Commands
- CCNA Exam Tips for OSPF Questions
1. What Is OSPF and Why It Replaced Older Protocols
Open Shortest Path First, universally known as OSPF, is one of the most widely deployed interior gateway protocols (IGPs) in enterprise networking today. Defined in RFC 2328 for OSPFv2 (IPv4) and RFC 5340 for OSPFv3 (IPv6), OSPF is an open-standard routing protocol, meaning it is not proprietary to any single vendor. This openness is one of the primary reasons it became the industry favorite over older protocols like RIP and even Cisco's proprietary EIGRP in multi-vendor environments.
To understand why OSPF rose to prominence, it helps to look at what came before it. The Routing Information Protocol (RIP) was one of the earliest dynamic routing protocols used in IP networks. RIP is a distance-vector protocol that uses hop count as its sole metric, with a maximum hop count of 15. Any destination more than 15 hops away is considered unreachable. RIP also broadcasts its entire routing table to neighbors every 30 seconds, regardless of whether anything has changed. These limitations made RIP impractical for anything beyond small networks. Convergence was slow, bandwidth was wasted on periodic updates, and the hop count limit severely restricted network size.
OSPF was designed from the ground up to address every one of these shortcomings. It uses a cost metric based on interface bandwidth rather than a simple hop count, it supports networks of virtually unlimited size through its hierarchical area design, and it converges dramatically faster because routers only send updates when a topology change actually occurs. Instead of broadcasting full routing tables on a timer, OSPF routers exchange link-state advertisements (LSAs) that describe the state of their directly connected links. Each router then independently builds a complete map of the network topology and calculates the shortest path to every destination using Dijkstra's Shortest Path First (SPF) algorithm.
2. OSPF Fundamentals: Link-State Protocol and Dijkstra's Algorithm
OSPF belongs to the family of link-state routing protocols. The term "link-state" refers to the fact that each router advertises the state (up or down, cost, network type) of its own directly connected links to all other routers in the same OSPF area. This is fundamentally different from distance-vector protocols, where routers only share their routing tables with directly connected neighbors.
The process works as follows. When an OSPF router comes online, it discovers its neighbors through the exchange of Hello packets. Once neighbor relationships are established, each router generates link-state advertisements (LSAs) that describe its connected interfaces, their IP addresses, subnet masks, costs, and the neighbors reachable through each link. These LSAs are flooded throughout the area so that every router receives the same set of LSAs. Each router stores all the LSAs it receives in a local database called the Link-State Database (LSDB). Because every router in an area receives the same LSAs, every router in that area has an identical LSDB.
With a complete LSDB in hand, each router runs Dijkstra's Shortest Path First algorithm to build a shortest-path tree (SPT) with itself as the root. The algorithm evaluates every possible path to every destination network and selects the path with the lowest cumulative cost. The results are then installed into the router's routing table. Because every router performs this calculation independently using the same data, the network achieves a consistent, loop-free forwarding topology.
OSPF Packet Types
OSPF uses five distinct packet types to manage neighbor discovery, database synchronization, and route updates. Understanding these is essential for the CCNA exam:
| Type | Packet Name | Purpose |
|---|---|---|
| 1 | Hello | Discover and maintain neighbor relationships |
| 2 | Database Description (DBD) | Summarize LSDB contents during initial adjacency |
| 3 | Link-State Request (LSR) | Request specific LSAs from a neighbor |
| 4 | Link-State Update (LSU) | Send requested LSAs or flood topology changes |
| 5 | Link-State Acknowledgment (LSAck) | Confirm receipt of LSAs (ensures reliability) |
3. OSPF Areas and the Role of Area 0
One of OSPF's most powerful design features is its support for a hierarchical, multi-area architecture. An OSPF area is a logical grouping of routers and networks that share the same link-state database. By dividing a large network into multiple areas, administrators can significantly reduce the amount of routing information each router must process, lower CPU and memory consumption, and contain the blast radius of topology changes so that an instability in one area does not trigger SPF recalculations across the entire network.
Why Area 0 Is Special
Area 0, also called the backbone area, is the core of every OSPF domain. All other areas must connect directly to Area 0, either through a physical link or through a virtual link. This is not merely a best practice; it is a hard requirement of the OSPF specification. The backbone area serves as the transit area for all inter-area traffic. When a packet needs to travel from a network in Area 1 to a network in Area 2, it must pass through Area 0 along the way. This star topology ensures a loop-free inter-area routing architecture.
Routers that sit at the boundary between Area 0 and another area are called Area Border Routers (ABRs). An ABR has interfaces in at least two areas, one of which must be Area 0. ABRs are responsible for summarizing routing information between areas by generating Type 3 Summary LSAs. Routers that connect the OSPF domain to an external routing domain (such as the internet or a network running a different protocol) are called Autonomous System Boundary Routers (ASBRs).
Key Area Concepts for the CCNA
- All OSPF areas must connect to Area 0 (the backbone)
- Routers within the same area share an identical LSDB
- ABRs connect non-backbone areas to Area 0 and summarize routes
- The CCNA 200-301 exam focuses primarily on single-area OSPF, but you must understand the concept of areas and why Area 0 exists
- Virtual links can be used to connect a disconnected area to Area 0, but this is considered a temporary fix, not a design goal
4. OSPF Neighbor Relationships and States
Before two OSPF routers can exchange routing information, they must first form a neighbor relationship. This process is initiated by Hello packets and progresses through a series of well-defined states. Understanding each state is critical for the CCNA exam and for real-world troubleshooting, because a neighbor stuck in a particular state tells you exactly where the adjacency formation process is failing.
The Seven OSPF Neighbor States
Down: This is the initial state. The router has not received any Hello packets from this neighbor. When a router first sends a Hello, the neighbor entry is created in Down state. If a neighbor has been active but its Dead timer expires without receiving a new Hello, the neighbor transitions back to Down.
Init: A Hello packet has been received from the neighbor, but it does not yet list the local router's Router ID in its "neighbor" field. This means the neighbor knows about us, but we have not confirmed that the neighbor has heard us. One-way communication is established.
2-Way: This is a pivotal state. The router has received a Hello from the neighbor that includes the local router's Router ID in its neighbor list, confirming bidirectional communication. At this point on multi-access networks, the DR/BDR election takes place. On point-to-point links, the routers proceed directly to forming a full adjacency. On multi-access networks, routers that are neither the DR nor the BDR (called DROther routers) will remain in the 2-Way state with each other; they only form full adjacencies with the DR and BDR.
ExStart: The two routers negotiate which one will be the master and which will be the slave for the database exchange process. The router with the higher Router ID becomes the master, which means it controls the sequence numbering of DBD packets.
Exchange: The routers exchange Database Description (DBD) packets that contain summaries of the LSAs in their respective LSDBs. Each router examines the summaries to determine which LSAs it is missing or which are more recent than what it currently has.
Loading: Based on the DBD exchange, each router sends Link-State Request (LSR) packets to ask for any LSAs it needs. The neighbor responds with Link-State Update (LSU) packets containing the full LSA data. This process continues until both routers have synchronized their databases.
Full: The databases are fully synchronized. The adjacency is complete, and the routers are now peers that share a common view of the network topology. This is the operational state for a healthy OSPF adjacency. In show command output, you should see "FULL" for adjacencies with the DR and BDR on multi-access networks, and "FULL" for all adjacencies on point-to-point links.
5. Router ID Selection Process
Every OSPF router must have a unique 32-bit Router ID (RID) that identifies it within the OSPF domain. The Router ID is written in dotted decimal notation, just like an IP address, but it is not necessarily an IP address that is reachable on the network. The selection process follows a strict priority order:
- Manually configured Router ID: If you explicitly set the Router ID using the
router-idcommand under the OSPF process, that value is used regardless of any interface addresses. This is the recommended best practice because it gives you full control and prevents unexpected changes if interfaces go down. - Highest loopback interface IP: If no Router ID is manually configured, OSPF selects the highest IP address among all active loopback interfaces. Loopback interfaces are preferred because they never go down (they are virtual interfaces), providing a stable Router ID.
- Highest active physical interface IP: If there are no loopback interfaces configured, OSPF selects the highest IP address among all active physical interfaces at the time the OSPF process starts.
clear ip ospf process or the router is reloaded. The exam loves to test this nuance.6. DR/BDR Election on Multi-Access Networks
On multi-access network segments (such as Ethernet LANs), OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR) to reduce the amount of OSPF traffic on the segment. Without a DR, every router on the segment would need to form a full adjacency with every other router, creating an O(n-squared) problem. The DR acts as a central point of contact: all routers on the segment form full adjacencies only with the DR and BDR, and the DR is responsible for flooding LSAs to all other routers on the segment.
How the Election Works
The DR/BDR election is based on two criteria, evaluated in this order:
- OSPF Interface Priority: The router with the highest OSPF priority on that interface becomes the DR, and the second highest becomes the BDR. The default priority is 1. Setting a router's priority to 0 makes it ineligible for DR or BDR election on that segment.
- Router ID (tiebreaker): If priorities are equal, the router with the highest Router ID wins the election.
Routers that are neither the DR nor the BDR are classified as DROther. DROther routers remain in the 2-Way state with each other and only achieve Full adjacency with the DR and BDR. This is normal behavior, not an error.
7. OSPF Cost Metric and Bandwidth Relationship
OSPF uses cost as its metric for path selection. The cost of a route is the sum of the costs of all outgoing interfaces along the path from the local router to the destination network. The cost of an individual interface is calculated using a simple formula:
By default, the reference bandwidth is 100 Mbps (100,000,000 bps). This means a 100 Mbps Fast Ethernet interface has a cost of 1, a 10 Mbps Ethernet interface has a cost of 10, and a 1.544 Mbps T1 serial link has a cost of 64. However, this default reference bandwidth creates a significant problem in modern networks: any interface with a bandwidth of 100 Mbps or higher (Fast Ethernet, Gigabit Ethernet, 10 Gigabit Ethernet) all receive a cost of 1, making them indistinguishable to OSPF.
The solution is to increase the reference bandwidth to a value that accommodates your fastest links. For example, setting the reference bandwidth to 10,000 (representing 10 Gbps) would give a 10 Gbps link a cost of 1, a 1 Gbps link a cost of 10, and a 100 Mbps link a cost of 100, providing meaningful differentiation.
| Interface | Bandwidth | Cost (Default 100 Mbps ref) | Cost (10 Gbps ref) |
|---|---|---|---|
| Serial (T1) | 1.544 Mbps | 64 | 6477 |
| Ethernet | 10 Mbps | 10 | 1000 |
| Fast Ethernet | 100 Mbps | 1 | 100 |
| Gigabit Ethernet | 1 Gbps | 1 | 10 |
| 10-Gigabit Ethernet | 10 Gbps | 1 | 1 |
8. Single-Area OSPF Configuration with Cisco IOS
The CCNA 200-301 exam heavily emphasizes single-area OSPF configuration. In a single-area deployment, all routers and networks belong to Area 0. While this does not leverage the hierarchical benefits of multi-area OSPF, it is simpler to configure and is perfectly adequate for small to medium-sized networks.
The Network Command
The network command under the OSPF router configuration mode does not announce networks directly. Instead, it tells the OSPF process which locally connected interfaces should participate in OSPF. Any interface whose IP address falls within the range specified by the network command and wildcard mask will be activated for OSPF, meaning OSPF Hello packets will be sent out of that interface and the connected network will be advertised.
Complete Configuration Example
Consider a router with the following interfaces: GigabitEthernet0/0 (192.168.1.1/24 connected to the LAN), GigabitEthernet0/1 (10.0.0.1/30 connected to another router), and a Loopback0 (1.1.1.1/32 used as the Router ID). Here is the full OSPF configuration:
Understanding the Wildcard Mask
The wildcard mask in the OSPF network command is the inverse of the subnet mask. Where a subnet mask has a 1, the wildcard mask has a 0, and vice versa. For example, a subnet mask of 255.255.255.0 corresponds to a wildcard mask of 0.0.0.255. A /30 subnet mask of 255.255.255.252 becomes a wildcard mask of 0.0.0.3. The wildcard mask defines which bits of the IP address must match exactly (0 bits) and which bits can vary (1 bits).
The Passive Interface Command
The passive-interface command tells OSPF to stop sending Hello packets out of a specified interface. The network connected to that interface is still advertised into OSPF; the router simply will not attempt to discover or form neighbor relationships through that interface. This is used on interfaces connected to end-user LANs, where there are no other OSPF routers and sending Hellos would be wasteful and a potential security risk.
router ospf) is locally significant to the router. It does not need to match between neighbors. However, the Area ID specified in the network command must match between neighbors for an adjacency to form.
9. Useful Show and Debug Commands
Knowing the right verification and troubleshooting commands is just as important as knowing how to configure OSPF. The CCNA exam expects you to interpret the output of these commands to identify issues and confirm correct operation.
show ip ospf neighbor
This is your go-to command for verifying OSPF adjacencies. It displays the Neighbor ID (Router ID of the neighbor), the current state of the adjacency, the Dead timer countdown, the neighbor's address, and the local interface connected to that neighbor.
In this output, notice that the local router has a Full adjacency with the DR (2.2.2.2) and BDR (3.3.3.3), but only a 2-Way relationship with the DROther (4.4.4.4). This is completely normal on a multi-access segment.
show ip route ospf
This command filters the routing table to display only routes learned through OSPF. OSPF routes are marked with "O" for intra-area routes, "O IA" for inter-area routes, and "O E1" or "O E2" for external routes.
The numbers in brackets represent [administrative distance/metric]. OSPF has a default administrative distance of 110. The metric is the total cost to reach the destination.
show ip ospf interface
This command provides detailed OSPF information for each interface, including the area assignment, cost, network type, hello and dead intervals, DR/BDR addresses, and neighbor count. It is invaluable for verifying configuration and diagnosing mismatches.
Additional Useful Commands
10. CCNA Exam Tips for OSPF Questions
OSPF is one of the most heavily tested topics on the CCNA 200-301 exam, appearing in the IP Connectivity domain which accounts for 25% of the total exam score. Here is a focused summary of the concepts and pitfalls you need to master before exam day:
Must-Know Facts for Exam Day
- OSPF uses protocol number 89 and multicast addresses 224.0.0.5 (AllSPFRouters) and 224.0.0.6 (AllDRouters)
- Default Hello interval is 10 seconds on broadcast and point-to-point networks, 30 seconds on NBMA networks
- Default Dead interval is 4 times the Hello interval (40 seconds on broadcast/point-to-point)
- Hello and Dead timers must match between neighbors or the adjacency will not form
- Area IDs must match between neighbors on the same link
- Subnet mask must match between neighbors (except on point-to-point links)
- Authentication type and credentials must match if authentication is configured
- Administrative distance of OSPF is 110
- The OSPF process ID is locally significant and does not need to match between routers
- DR/BDR election is non-preemptive
Common Exam Scenarios
Scenario 1 - Neighbors not forming: You are shown a topology where two routers are connected but OSPF neighbors are not forming. Check the following in order: Are the interfaces in the same subnet? Are they in the same OSPF area? Do the Hello/Dead timers match? Is one interface set as passive? Is there an ACL blocking protocol 89? Is the authentication configuration consistent?
Scenario 2 - Suboptimal routing: Traffic is taking a longer path than expected. Check the OSPF cost on each interface along both paths. Remember that all interfaces 100 Mbps and above have the same default cost of 1. Verify whether the reference bandwidth has been adjusted, and whether it has been set consistently on all routers.
Scenario 3 - DR election questions: You are given OSPF priorities and Router IDs and asked to identify the DR and BDR. Remember: highest priority wins, Router ID breaks ties, a priority of 0 means the router cannot be DR or BDR, and the election is non-preemptive.
Configuration Checklist
When configuring single-area OSPF on the exam, always follow this sequence:
- Assign IP addresses to all interfaces and bring them up
- Create a loopback interface or manually assign a Router ID
- Start the OSPF process with
router ospf [process-id] - Use
networkcommands with correct wildcard masks and area 0 - Set passive interfaces on LAN segments where no OSPF neighbors exist
- Adjust the reference bandwidth if the network has links faster than 100 Mbps
- Verify with
show ip ospf neighborandshow ip route ospf
network [ip] 0.0.0.0 area 0 matches only that exact IP address. This is the most precise way to enable OSPF on a specific interface and is commonly used in practice and on the exam. For example, network 192.168.1.1 0.0.0.0 area 0 enables OSPF only on the interface that has the IP address 192.168.1.1.Wrapping Up
OSPF is the backbone of modern enterprise routing and one of the most important topics on the CCNA 200-301 exam. By understanding its link-state operation, how neighbors form adjacencies through the seven states, the role of areas and the backbone, the DR/BDR election process, and how cost drives path selection, you will have a solid foundation not only for passing the exam but for working with real production networks.
Focus your study on single-area OSPF configuration using the network command, wildcard masks, and passive interfaces. Practice reading and interpreting show command output, especially show ip ospf neighbor, show ip route ospf, and show ip ospf interface. Know the neighbor requirements that must match (area, timers, authentication, subnet) and the ones that do not need to match (process ID, Router ID). Build labs in Cisco Packet Tracer or GNS3 and configure OSPF between multiple routers to see these concepts in action.
For more in-depth study on IP Connectivity topics, visit our IP Connectivity Study Guide, or test your knowledge with our Practice Questions and Interactive Labs.