OSPF stands for Open Shortest Path First. It is a link-state Interior Gateway Protocol (IGP) that distributes IP routing information within a routing domain. Routers exchange link-state information and use Dijkstra's shortest path first algorithm to calculate paths according to configured costs. OSPFv2 is defined in RFC 2328.
What Is OSPF?
OSPF builds a topology database for each area to which a router belongs. Routers use that information to calculate intra-area paths, then apply rules for inter-area and external routes. A router in a multi-area network does not hold a detailed map of every link in every area.
As an IGP, OSPF supports internal routing in enterprise and service-provider networks. It can operate alongside BGP, which provides policy-based route distribution between autonomous systems and within an AS through iBGP.
OSPF cost is a configurable interface metric. Many implementations calculate an initial value from reference bandwidth and interface bandwidth, but that formula is not a universal protocol requirement. Administrators can set costs explicitly. OSPF also considers route type, so “the lowest numeric cost always wins” is incomplete.
The principal versions are:
- OSPFv2: provides IPv4 routing. RFC 2328 remains the base specification, with subsequent extensions and updates.
- OSPFv3: was specified for IPv6 in RFC 5340. The address-family extensions in RFC 5838 also support IPv4, where implemented.
Key OSPF Terms at a Glance
| Term | Meaning |
|---|---|
| Router ID | A 32-bit identifier, commonly written in dotted-decimal notation, that must be unique within the OSPF domain |
| Area | A grouping of OSPF links and routers that limits the distribution of detailed topology information |
| Area 0 | The backbone used for inter-area routing in the standard hierarchy |
| Neighbor | A router discovered on an OSPF link |
| Adjacency | A neighbor relationship used for database synchronization and reliable exchange of link-state information |
| Hello | A packet used to discover and maintain neighbor relationships |
| LSA | A link-state advertisement describing topology, reachability or extension information, depending on type |
| LSDB | The link-state database containing the applicable LSAs |
| Cost | An interface or route metric used in path calculations |
| DR / BDR | Designated Router and Backup Designated Router on eligible multi-access networks |
| ABR | Area Border Router participating in the backbone and another area |
| ASBR | A router that introduces external routing information into OSPF |
| SPF | The shortest path first calculation based on link-state information |
How Does OSPF Work?
Neighbor discovery and adjacency
OSPF uses Hello packets to discover and maintain neighbors. OSPFv2 commonly uses multicast address 224.0.0.5 on broadcast networks, but packet destinations and discovery behavior depend on network type. The protocol runs directly over IP as protocol number 89, rather than over TCP or UDP.
Neighbors need compatible parameters, including area, timers, authentication and relevant network options. Subnet checks depend on the interface's network type. Duplicate router IDs, MTU mismatches or filtering can also prevent normal adjacency establishment or database exchange.
Some platforms commonly use 10-second Hello and 40-second dead intervals on broadcast links. Other network types and configurations differ. A neighbor can also be declared unavailable through an interface event or integration with BFD, rather than only by waiting for the dead timer.
Building and flooding the LSDB
Routers originate LSAs and reliably exchange them with the appropriate neighbors. In stable operation, routers in the same area agree on the area's topology information, subject to the flooding scope of each LSA. An ABR maintains information for each attached area.
A topology change can trigger a new LSA. Sequence numbers, acknowledgments, retransmissions and aging help distribute current information. OSPF also refreshes self-originated LSAs periodically; the base specification uses a 30-minute refresh interval. It does not broadcast the complete routing table on a fixed schedule, although initial synchronization and retransmissions still generate traffic.
SPF, cost and route selection
Each router calculates paths with itself as the root. For comparable intra-area paths, the total cost is the sum of the outgoing interface costs along the path. Equal-cost alternatives may be installed, subject to platform limits and configuration.
For example, suppose R1 has a direct link to R3 with configured cost 10. A path through R2 has costs 1 and 1, giving a total of 2. Within the same area and route class, OSPF prefers the two-hop path. These are explicit example costs, not a claim about the default cost of particular link speeds.
Route type matters before a simple cost comparison. OSPF prefers intra-area over inter-area paths and internal over external paths. External metric types have additional rules. A route learned from another protocol also competes according to the router's route-selection policy.
Cisco IOS XE commonly uses a 100 Mbps reference bandwidth for automatic OSPF costs. That can give several faster link speeds the same minimum cost. The Cisco OSPF FAQ describes adjusting reference bandwidth. Apply a consistent metric design across the routing domain.
Convergence
Recovery includes failure detection, LSA propagation, routing calculations and forwarding updates. The elapsed time depends on topology, throttling, timers and platform load. Not every LSA change requires the same calculation, and implementations can optimize processing.
OSPF's stable calculations support consistent paths, but routers do not all update their forwarding entries simultaneously. Transient loops or blackholes can occur during convergence. BFD can shorten detection without guaranteeing a particular end-to-end recovery time.
OSPF Areas and Topology
A small deployment can use a single area. Larger networks can use multiple areas to contain detailed topology and organize route distribution. Aggregation requires appropriate addressing and configuration; creating an area does not automatically summarize all its prefixes into one route.
In the standard multi-area design, Area 0 is the backbone and non-backbone areas connect to it. Virtual links support particular logical backbone connections, but do not replace a sound physical design. ABRs exchange reachability between areas, while ASBRs introduce external routes.
An internal change can affect inter-area reachability even though remote routers do not receive the full local topology. Areas reduce the scope of detailed information rather than guaranteeing that every failure has only local consequences.
DR and BDR on multi-access networks
Broadcast and NBMA networks can elect a DR and BDR to reduce adjacency overhead. Eligible routers use interface priority, with router ID as a tie-breaker. Priority zero excludes a router from election. An existing DR is not normally replaced merely because a router with a higher priority or router ID joins later.
Other routers form full adjacencies with both the DR and BDR; relationships between two DROther routers normally remain at 2-Way. Point-to-point networks do not need a DR/BDR. These roles organize OSPF database exchange, not the forwarding path of every application packet.
Stub areas and NSSA
Stub areas exclude AS-external LSAs and use a default route for external reachability. An NSSA permits a local ASBR to originate Type 7 external information while excluding ordinary Type 5 LSAs; RFC 3101 defines NSSA behavior. Variants often called totally stubby or totally NSSA add restrictions on inter-area information, with details depending on the implementation.
OSPF LSA Types
The following table covers common OSPFv2 LSAs. OSPFv3 uses different encodings and additional LSA types; the numbers should not be transferred unchanged between versions.
| Type | Name | Originator | Flooding scope |
|---|---|---|---|
| 1 | Router LSA | Each router, per attached area | Area |
| 2 | Network LSA | DR for a transit multi-access network | Area |
| 3 | Network Summary LSA | ABR | Area into which it is originated |
| 4 | ASBR Summary LSA | ABR | Area into which it is originated |
| 5 | AS External LSA | ASBR or translating NSSA ABR | AS-wide, excluding restricted areas such as stub areas and NSSAs |
| 7 | NSSA External LSA | ASBR in an NSSA | NSSA; eligible routes can be translated to Type 5 by an ABR |
Type 3 and Type 4 LSAs convey inter-area information, but each individual LSA has area scope: ABRs originate the information into the appropriate areas. Type 7 translation follows NSSA rules rather than translating every advertisement unconditionally.
OSPFv2 opaque LSAs use Types 9, 10 and 11 for link, area and AS scope. They support extensions such as traffic engineering; they should not be dismissed as irrelevant simply because they are outside the basic route table. RFC 5250 specifies the opaque LSA mechanism.
OSPF Configuration Example
This illustrative Cisco IOS/IOS XE-style lab uses two routers in Area 0. Their connected transit interfaces are GigabitEthernet0/0, and each has a loopback. Adapt interface names and syntax to the platform; the example is not NFWare CLI.
R1:
interface GigabitEthernet0/0
ip address 10.0.0.1 255.255.255.252
no shutdown
interface Loopback0
ip address 192.0.2.1 255.255.255.255
router ospf 1
router-id 192.0.2.1
passive-interface default
no passive-interface GigabitEthernet0/0
network 10.0.0.0 0.0.0.3 area 0
network 192.0.2.1 0.0.0.0 area 0R2:
interface GigabitEthernet0/0
ip address 10.0.0.2 255.255.255.252
no shutdown
interface Loopback0
ip address 198.51.100.1 255.255.255.255
router ospf 1
router-id 198.51.100.1
passive-interface default
no passive-interface GigabitEthernet0/0
network 10.0.0.0 0.0.0.3 area 0
network 198.51.100.1 0.0.0.0 area 0The network statements select local interfaces for OSPF using wildcard masks. The process ID 1 is locally significant and need not match between routers; the area and other adjacency parameters must be compatible. Passive interfaces can advertise their connected networks without forming neighbors.
Verify with:
show ip ospf neighbor
show ip ospf interface GigabitEthernet0/0
show ip ospf database
show ip route ospfWith compatible settings and a working link, each router should reach Full adjacency and learn the other loopback as an intra-area route. The exact DR/BDR role and displayed metric depend on election history and interface settings. These are expected results, not captured output from a running lab.
This example omits production authentication and platform-specific security policy. Use supported cryptographic authentication and appropriate key management for a real deployment; RFC 5709 defines HMAC-SHA authentication for OSPFv2. Authentication protects protocol exchanges but does not encrypt user traffic.
NFWare's vCGNAT high-availability configuration provides a separate product-specific OSPF example, including interface cost control. Follow its CLI syntax rather than copying the Cisco lab into vCGNAT.
OSPF vs IS-IS, RIP, EIGRP and BGP
| Protocol | Approach | Main scope | Design considerations |
|---|---|---|---|
| OSPF | Link-state, SPF | Internal routing | Areas and an Area 0 backbone; separate OSPFv2/v3 capabilities |
| IS-IS | Link-state, SPF | Internal routing | Level 1/Level 2 hierarchy; common in provider and data-center designs |
| RIP | Distance-vector | Internal routing | Hop-count metric; maximum usable hop count of 15 |
| EIGRP | Distance-vector with DUAL | Internal routing | Metric and feature support depend on implementation |
| BGP | Path-vector, policy-based selection | Inter-AS and internal BGP route distribution | Uses eBGP between ASes and iBGP within an AS |
IS-IS is an important alternative to OSPF for internal routing, including operator networks. Integrated IS-IS carries IP reachability as described in RFC 1195. Both protocols use link-state information and SPF, but their hierarchy and protocol operation differ. IS-IS Level 1/Level 2 should not be treated as a direct renaming of OSPF areas.
For a telecom operator, the choice involves topology, convergence design, tooling and platform support. For developers, an IGP supplies network reachability; it does not determine application health. IPv4 brokers and address holders should distinguish internal path selection from public prefix authorization and inter-domain advertisement. An internal OSPF route alone does not establish global reachability.
Benefits and Limitations of OSPF
OSPF provides an open, widely implemented method for internal route distribution. Its hierarchy limits the spread of detailed topology, its metrics permit engineered path preferences, and eligible equal-cost routes can share forwarding load.
The main operational limits are:
- Resource use: database size, change frequency and routing calculations consume memory and processing capacity.
- Design complexity: addressing, areas, ABRs, external redistribution and summarization need coordination.
- Metric limitations: standard cost does not automatically measure current latency, loss or application load.
- Recovery dependencies: failure detection, flooding, calculation and forwarding updates all affect convergence.
- Interoperability details: an open standard does not guarantee identical support for every extension or authentication method.
These considerations also apply to virtualized network functions, where resource allocation and scheduling influence control-plane performance. Evaluate behavior under representative load rather than assuming a universal convergence time.
Frequently Asked Questions
What does OSPF stand for?
OSPF stands for Open Shortest Path First. It is an open-standard link-state IGP that uses shortest path first calculations for internal routing.
What is the difference between OSPF and IS-IS?
Both are link-state IGPs using SPF. OSPF uses areas with a backbone hierarchy; IS-IS uses Level 1 and Level 2 routing. Protocol formats, adjacency behavior and deployment choices differ.
What is the difference between OSPF and BGP?
OSPF distributes internal routing information using link-state calculations. BGP distributes reachability according to policy, using eBGP between autonomous systems and iBGP within one AS. Networks can use both together.
How is OSPF cost calculated?
Cost is a configurable metric. Platforms may calculate an initial value from reference bandwidth and interface bandwidth, or administrators may assign it explicitly. Route type and external-route rules also influence selection.
What is the difference between OSPFv2 and OSPFv3?
OSPFv2 supports IPv4. OSPFv3 was specified for IPv6 and uses revised packet and LSA formats; address-family extensions can also support IPv4 where implemented.
Does OSPF use TCP or UDP?
Neither. OSPF runs directly over IP using protocol number 89 and provides its own mechanisms for reliable link-state exchange.
Conclusion
OSPF combines area-based link-state information with cost-based path calculations and rules for inter-area and external routing. Reliable operation depends on compatible neighbors, a coherent area and metric design, controlled redistribution and tested recovery behavior. Understand those mechanisms alongside alternatives such as IS-IS and complementary protocols such as BGP.