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.
| Aspect | OSPF/link-state behavior | Distance-vector contrast |
|---|---|---|
| Information exchanged | Topology details carried in LSAs | Reachability, distance, and direction learned from neighbors |
| Topology knowledge | Routers build an area-wide topology database | Routers commonly know routes through neighboring directions |
| Route computation | Each router runs SPF, also called Dijkstra's algorithm | Routes are calculated from received distance information |
| Update behavior | Incremental, event-driven LSA flooding, with periodic refresh behavior | Often periodic route advertisements, depending on the protocol |
| Loop prevention characteristics | A consistent topology view and SPF calculation help limit loops | Requires distance-vector safeguards and may converge more gradually |
OSPF Characteristics at a Glance
| Characteristic | OSPF behavior or value | Why it matters |
|---|---|---|
| Protocol type | Open-standard link-state IGP | Provides dynamic routing within an autonomous system and supports multi-vendor operation. |
| Standardization and interoperability | Defined by open standards; implementation support varies | Devices from different vendors can interoperate when compatible features are used. |
| Classless/VLSM support | Carries prefix-length information | Different subnet sizes, such as /30 links and /24 LANs, can coexist. |
| Metric | Interface cost; lower cumulative cost wins | Lets the network prefer paths according to configured or calculated cost. |
| Default administrative distance | 110 | Determines preference for OSPF compared with routes from other sources; it is not the OSPF path metric. |
| Update model | Incremental and event-driven LSAs | Topology changes do not require regular full routing-table exchanges. |
| Equal-cost load balancing | ECMP support | Multiple paths with the same total cost can be installed and used. |
| Core calculation method | SPF/Dijkstra calculation over the LSDB | Each 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
| Parameter | Expected relationship | Effect of mismatch |
|---|---|---|
| Area ID | Routers on the link use the same OSPF area | Hellows are rejected or a neighbor does not form. |
| Hello/dead timers | Timers match on the shared link | Routers may fail to recognize each other as compatible. |
| Authentication | Authentication method and credentials agree, when enabled | Authenticated packets fail validation. |
| Network type | Network-type behavior is compatible | Neighboring and DR/BDR behavior may fail. |
| IP subnet compatibility | Interfaces share a compatible subnet and can communicate | OSPF packets cannot form a usable relationship. |
| Stub-area settings | Area-wide stub-related settings agree where applicable | Adjacency 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:
| Address | Name | Primary recipients | Typical purpose |
|---|---|---|---|
224.0.0.5 | AllSPFRouters | All OSPF routers on the local segment | General OSPF communication, including Hellos and other protocol traffic as appropriate. |
224.0.0.6 | AllDRouters | Designated Router and Backup Designated Router | Communication 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.
- Routers send Hello packets and discover compatible neighbors.
- Neighbors form the adjacency required by the network type and begin database exchange.
- LSAs are flooded and synchronized so routers can build a consistent LSDB for the area.
- Each router runs the Shortest Path First (SPF) algorithm, also called Dijkstra's algorithm, using itself as the calculation root.
- The SPF result forms a shortest-path tree. OSPF derives best routes and next hops from that tree.
- 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 structure | Stored information | How it is populated | Role in route selection |
|---|---|---|---|
| Neighbor table | Discovered OSPF neighbors, interface relationships, and neighbor states | Hello packets and adjacency processing | Shows whether the router has usable OSPF peers for synchronization. |
| Link-state database/topology table | LSAs describing the OSPF topology for an area | LSA flooding and database synchronization | Input to SPF and the best-path calculation. |
| Routing table | Selected destination prefixes, next hops, and outgoing interfaces | SPF results plus route installation and route-source selection | Used 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 10The 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 protocolsUse 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 protocolsNeighbor 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 databaseAn 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 ospfExam-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.5is AllSPFRouters;224.0.0.6is 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.