3 OSPF Fundamentals and Configuration
Learn how OSPF discovers neighbors, builds routes, supports a basic single-area configuration, and is verified and troubleshot.
How calculates routes
Open Shortest Path First () is a link-state interior gateway protocol. Routers share information about links and networks, build a , and independently calculate shortest paths with the Shortest Path First (SPF) algorithm. The resulting best routes are installed in the routing table when selected and usable.
supports equal- paths, so a router can use multiple routes when their costs are equal. For a path, the total is the sum of its outgoing interface costs:
Here, represents the of an outgoing interface on the path. prefers the path with the lowest total . The exact default calculation can depend on the vendor and configuration.
Areas and router identity
An is a set of -connected links and routers that share an -specific LSDB. In a single- network, all participating interfaces belong to the same , commonly 0.
The process ID identifies a local process on a router and does not need to match the process ID on a neighboring router. The router ID is a 32-bit identifier. Explicitly configuring a unique, stable router ID makes identification and troubleshooting easier.
Neighbors and adjacencies
Routers send Hello packets to discover and maintain neighbors. Once bidirectional communication is confirmed, routers form adjacencies where required and synchronize their LSDBs. They then flood link-state advertisements (LSAs) within the . Each router runs SPF against its own LSDB to derive routes; does not simply pass a neighbor’s finished routing table along.
The common neighbor states, in order, are:
Down — no recent Hello has been received.
Init — a Hello has been received, but it does not list this router as a neighbor.
2-Way — Hellos confirm communication in both directions. On a shared broadcast network, two routers that are neither the DR nor BDR may remain in this state; that can be normal.
ExStart and Exchange — routers establish database-exchange roles and exchange summaries of their LSDBs.
Loading — routers request and receive needed LSAs.
Full — the databases are synchronized.
On broadcast networks, elects a Designated Router (DR) and Backup Designated Router (BDR) to reduce the number of adjacencies needed. On point-to-point links, the routers form an directly.
Basic single- configuration
The example connects two LANs through a point-to-point transit network. It uses Cisco IOS/IOS XE syntax; interface names may differ by device. Configure interface addresses first, then enable on interfaces whose addresses match the network statements. A is the inverse of a subnet mask; for example, 0.0.0.255 matches any address in a /24. The network command both selects interfaces and assigns them to an .
R1:
R2:
The example uses process 1 on both routers, but process IDs are local and need not match. The two sides of the transit link must use compatible settings and the same . Cisco also supports enabling directly under an interface with ip <process-id> <-id>.
Verification and troubleshooting
On Cisco IOS/IOS XE, learned routes are commonly marked O in show ip route. For example, O 192.168.20.0/24 indicates an -learned intra- route. A route appears in the routing table only if it is selected as a best route and is usable.
Use these commands to check the neighbor relationship, -enabled interfaces, LSDB, and routes:
A healthy point-to-point should reach Full, and each router should learn the other router’s LAN prefix. If a neighbor is absent or stuck before Full, troubleshoot in this order:
Confirm both interfaces are up and have addresses in the expected connected subnet; test basic IP reachability.
Check that is enabled on the intended interfaces and that both interfaces use the same and compatible type.
Compare Hello and dead intervals, authentication settings, and network type; check that router IDs are unique.
If the neighbor is stuck in ExStart or Exchange, check for an interface MTU mismatch and other database-description exchange issues.
Confirm that an interface is not configured as passive if it must form a neighbor relationship. Depending on the configuration, a passive interface can advertise its connected network while suppressing neighbor-forming Hellos.
If the neighbor reaches Full but a route is missing, check whether the destination network is included in , whether its LSA is present in the LSDB, and whether another route is preferred.
, subnet, timer, and router-ID mismatches can prevent neighbor formation. An MTU mismatch is a common cause of neighbors remaining in ExStart or Exchange.