VMware ESXi and vSphere Cluster Management

OSPF Overview: Link-State Routing Fundamentals

Learn how OSPF works as an open-standard link-state IGP, including neighbors, LSAs, LSDBs, SPF calculation, costs, multicast, areas, and troubleshooting.

What Is OSPF?

OSPF, or Open Shortest Path First, is a dynamic interior gateway protocol (IGP). An IGP routes traffic within a single autonomous system, such as an organization's enterprise network.

OSPF is a link-state routing protocol. Instead of simply learning a distance and next hop from a neighbor, each router builds a database describing the network topology. The router then independently calculates its best paths.

OSPF is an open standard, so supported devices from different vendors can interoperate. This differs from historically proprietary protocols such as EIGRP, although the exact OSPF features and configuration commands available vary by vendor and software version.

Link-State Routing Compared with Distance-Vector Routing

A distance-vector router generally learns routes by receiving distance and direction information from neighbors. In a traditional design, routers may periodically exchange substantial routing information and rely on mechanisms such as split horizon, route poisoning, or hold-down timers to reduce loops.

OSPF distributes topology information in link-state advertisements (LSAs). Routers in an OSPF area synchronize this information into a shared link-state database (LSDB). Each router uses the LSDB to calculate paths locally rather than receiving a complete routing table from a neighbor.

AspectOSPF/link-state behaviorDistance-vector contrast
Information exchangedTopology details carried in LSAsReachability, distance, and direction learned from neighbors
Topology knowledgeRouters build an area-wide topology databaseRouters commonly know routes through neighboring directions
Route computationEach router runs SPF, also called Dijkstra's algorithmRoutes are calculated from received distance information
Update behaviorIncremental, event-driven LSA flooding, with periodic refresh behaviorOften periodic route advertisements, depending on the protocol
Loop prevention characteristicsA consistent topology view and SPF calculation help limit loopsRequires distance-vector safeguards and may converge more gradually

OSPF Characteristics at a Glance

CharacteristicOSPF behavior or valueWhy it matters
Protocol typeOpen-standard link-state IGPProvides dynamic routing within an autonomous system and supports multi-vendor operation.
Standardization and interoperabilityDefined by open standards; implementation support variesDevices from different vendors can interoperate when compatible features are used.
Classless/VLSM supportCarries prefix-length informationDifferent subnet sizes, such as /30 links and /24 LANs, can coexist.
MetricInterface cost; lower cumulative cost winsLets the network prefer paths according to configured or calculated cost.
Default administrative distance110Determines preference for OSPF compared with routes from other sources; it is not the OSPF path metric.
Update modelIncremental and event-driven LSAsTopology changes do not require regular full routing-table exchanges.
Equal-cost load balancingECMP supportMultiple paths with the same total cost can be installed and used.
Core calculation methodSPF/Dijkstra calculation over the LSDBEach router selects paths from its topology view.

OSPF Cost and Route Selection

OSPF cost is the primary metric used to select paths. An interface has a cost, and the cost of a route is the sum of the outbound interface costs along that path. OSPF prefers the route with the lower total cost.

On many platforms, an interface cost is calculated from a bandwidth reference value divided by the interface bandwidth. The exact default reference value and command syntax are platform-dependent. High-bandwidth interfaces can therefore require a larger, consistently configured reference bandwidth in modern networks. A manually configured interface cost overrides the calculated value for that interface.

For example, suppose R1 can reach a destination by two paths:

  • Path A: interface costs of 10 and 20, for a total cost of 30.
  • Path B: interface costs of 20 and 30, for a total cost of 50.

OSPF selects Path A because 30 is lower than 50. If two distinct paths each have a total cost of 20, OSPF can use both as equal-cost multipath (ECMP) routes, subject to platform limits and forwarding behavior.

Administrative distance is different from a routing protocol metric. It is a route-source preference used when a router compares routes learned from different sources. The default administrative distance for OSPF is 110. OSPF cost chooses among OSPF paths; administrative distance helps choose between OSPF and another route source.

VLSM and Classless Routing

OSPF is classless: it carries both a network prefix and its prefix length. A design can therefore use /30 or /31 point-to-point links, /24 LANs, and other subnet sizes without assuming a single classful mask. This is variable-length subnet masking (VLSM).

How OSPF Discovers Neighbors

Before routers can synchronize most link-state information, they must discover eligible OSPF-speaking routers on a shared link. They do this with Hello packets. A router that receives compatible Hellos forms a neighbor relationship and maintains it with continued Hello and dead-timer processing.

A neighbor is an OSPF-speaking router discovered on a shared link. An adjacency is a neighbor relationship that has progressed to database synchronization as required by the network type and the routers' roles. Not every neighbor on every network type becomes fully adjacent with every other router.

Neighbor Relationship Requirements

ParameterExpected relationshipEffect of mismatch
Area IDRouters on the link use the same OSPF areaHellows are rejected or a neighbor does not form.
Hello/dead timersTimers match on the shared linkRouters may fail to recognize each other as compatible.
AuthenticationAuthentication method and credentials agree, when enabledAuthenticated packets fail validation.
Network typeNetwork-type behavior is compatibleNeighboring and DR/BDR behavior may fail.
IP subnet compatibilityInterfaces share a compatible subnet and can communicateOSPF packets cannot form a usable relationship.
Stub-area settingsArea-wide stub-related settings agree where applicableAdjacency formation or database exchange can fail.

Other operational issues can also prevent a full adjacency, including an MTU mismatch, a passive interface, or an interface that is down.

Multicast Communication

On applicable IPv4 OSPF network types, routers use multicast for control-plane communication:

AddressNamePrimary recipientsTypical purpose
224.0.0.5AllSPFRoutersAll OSPF routers on the local segmentGeneral OSPF communication, including Hellos and other protocol traffic as appropriate.
224.0.0.6AllDRoutersDesignated Router and Backup Designated RouterCommunication directed to the DR and BDR on a multi-access segment.

Multicast behavior depends on the OSPF network type. Some point-to-point, nonbroadcast, or specially configured scenarios use unicast instead. These addresses are link-local multicast destinations and are not routed across the network like ordinary application traffic.

DR and BDR on Multi-Access Networks

On a broadcast or other multi-access network, creating a full adjacency between every pair of routers would create unnecessary overhead. OSPF elects a Designated Router (DR) and a Backup Designated Router (BDR). Routers exchange topology information through these roles, reducing the number of relationships required on the shared segment. The BDR is prepared to take over if the DR fails.

From LSAs to Routes

An LSA, or Link-State Advertisement, is an information unit that describes OSPF topology details. Routers flood appropriate LSAs through an area, and neighboring routers acknowledge and synchronize them.

  1. Routers send Hello packets and discover compatible neighbors.
  2. Neighbors form the adjacency required by the network type and begin database exchange.
  3. LSAs are flooded and synchronized so routers can build a consistent LSDB for the area.
  4. Each router runs the Shortest Path First (SPF) algorithm, also called Dijkstra's algorithm, using itself as the calculation root.
  5. The SPF result forms a shortest-path tree. OSPF derives best routes and next hops from that tree.
  6. The selected routes are installed in the IP routing table if they are eligible and win route-source selection.

This shared topology view and independent SPF calculation help OSPF converge quickly and limit many routing-loop scenarios. They do not guarantee that every possible configuration or failure can never produce a loop; incorrect filtering, redistribution, implementation behavior, or inconsistent information can still cause problems.

OSPF Data Structures

Data structureStored informationHow it is populatedRole in route selection
Neighbor tableDiscovered OSPF neighbors, interface relationships, and neighbor statesHello packets and adjacency processingShows whether the router has usable OSPF peers for synchronization.
Link-state database/topology tableLSAs describing the OSPF topology for an areaLSA flooding and database synchronizationInput to SPF and the best-path calculation.
Routing tableSelected destination prefixes, next hops, and outgoing interfacesSPF results plus route installation and route-source selectionUsed to forward packets.

The operational flow is therefore: neighbor discovery → adjacency and LSDB synchronization → SPF calculation → route installation. A neighbor can exist without a full adjacency, and information in the LSDB is not automatically the same as a route installed in the routing table.

OSPF Areas and Scalability

Large OSPF deployments use areas as a hierarchical design mechanism. Area 0 is the backbone area, and other areas connect logically through it. An Area Border Router (ABR) connects OSPF areas.

Areas help constrain LSA flooding and limit how often routers need to recalculate SPF for changes that remain inside another area. They can also reduce the size of topology databases and make operational boundaries clearer.

Route summarization combines multiple more-specific prefixes into a shorter summary prefix. Summarization should be performed at an appropriate boundary so that it accurately represents reachable networks and does not hide failures. ABRs commonly summarize routes between OSPF areas. An Autonomous System Boundary Router (ASBR) injects external routes into OSPF, and depending on the route type and implementation, it may summarize those external routes.

Small Area-Based Example

Imagine a backbone Area 0 connected through an ABR to Area 10. Three LAN prefixes exist inside Area 10. Routers in Area 10 maintain detailed information for their local area, while the ABR can advertise an appropriate summary toward Area 0. A topology change confined to Area 10 can therefore have less impact on routers elsewhere than the same design without area separation.

Practical OSPF Examples

Neighbor-to-Route Workflow

R1 and R2 share a point-to-point link. OSPF is enabled on both interfaces and both interfaces belong to Area 0. They exchange Hello packets with matching area, timers, authentication, network type, and subnet information. After the neighbor relationship progresses to the required adjacency state, they synchronize LSAs. R1 adds R2's topology information to its LSDB, runs SPF, calculates a path to a LAN advertised by R2, and installs the resulting route in its routing table.

Three OSPF Tables in a Three-Router Topology

In a topology containing R1, R2, and R3:

  • The neighbor table on R1 may show R2 and R3, along with their interfaces and states.
  • The LSDB on R1 contains LSAs describing routers, links, networks, and relevant area topology—not merely a list of final next hops.
  • The routing table contains only the best eligible routes selected from SPF results and other route-selection rules.

Illustrative Cisco IOS-Style Configuration

The following is a compact illustration, not a complete deployment design. The exact syntax and behavior can vary by platform.

router ospf 1
 router-id 1.1.1.1
 network 10.0.12.0 0.0.0.3 area 0
!
interface GigabitEthernet0/0
 ip ospf 1 area 0
 ip ospf cost 10

The example shows an OSPF process, an explicit router ID, network-based activation, interface-based activation, area assignment, and a manually configured interface cost. In a real design, avoid unintentionally enabling OSPF on interfaces, use consistent addressing and area planning, and verify platform-specific requirements.

Useful Verification Commands

show ip ospf neighbor
show ip ospf database
show ip route ospf
show ip ospf interface brief
show ip protocols

Use show ip ospf neighbor for the neighbor table, show ip ospf database for the LSDB, and show ip route ospf for OSPF-installed routes. Interface costs, timers, network type, and other interface-level details are commonly examined with show ip ospf interface.

OSPF Troubleshooting

No OSPF Neighbor Appears

Check whether OSPF is enabled on the connected interface and whether both interfaces are up. Also verify matching area IDs, Hello and dead timers, authentication, compatible subnets, and whether a passive-interface setting prevents Hellos from being sent.

show ip ospf neighbor
show ip ospf interface brief
show ip ospf interface
show ip protocols

Neighbor Does Not Reach Full Adjacency

Investigate MTU mismatches, network-type mismatches, DR/BDR behavior on a multi-access segment, and incompatible stub-area settings. The neighbor state and database contents can help identify where progress stopped.

show ip ospf neighbor
show ip ospf interface
show ip ospf database

An Expected OSPF Route Is Missing

Confirm that topology information has synchronized and that the destination is advertised into the relevant area. Check whether another route source has won based on administrative distance, whether a different OSPF path is preferred, or whether filtering or summarization affects visibility.

show ip ospf database
show ip route ospf
show ip route <prefix>

Traffic Uses an Unexpected Path

Compare the actual interface costs with the assumed values. Check for inconsistent reference bandwidth, manually configured costs, or multiple equal-cost paths.

show ip ospf interface
show ip route <prefix>
show running-config | section router ospf

Exam-Relevant Notes

  • OSPF is an open-standard, link-state IGP used within an autonomous system.
  • OSPF uses LSAs and an LSDB, then runs SPF/Dijkstra to calculate routes.
  • OSPF cost is cumulative and lower is preferred.
  • The default OSPF administrative distance is 110; administrative distance is not the same as OSPF cost.
  • OSPF supports classless routing and VLSM.
  • 224.0.0.5 is AllSPFRouters; 224.0.0.6 is AllDRouters.
  • A neighbor relationship is not necessarily a full adjacency.
  • DR and BDR reduce adjacency overhead on multi-access networks.
  • Area 0 is the OSPF backbone; ABRs connect areas, and ASBRs inject external routes.
  • OSPF can install multiple equal-cost paths through ECMP.

For related study, continue with OSPF overview and fundamentals.