How to Configure and Verify Single Area OSPFv2

How to configure and verify single area OSPFv2

As networks grow beyond a handful of routers, manually configuring static routes on every device becomes unmanageable — one new subnet means updating routes on every router in the path. Dynamic routing protocols solve this by letting routers automatically discover the network topology and exchange routing information with each other. OSPF (Open Shortest Path First) is one of the most widely used dynamic routing protocols in enterprise networks, and OSPFv2 specifically handles IPv4 routing. This article covers single-area OSPF — the simplest and most common starting point for understanding OSPF.

What Problem Does OSPF Solve?

Static routes work fine for small, stable networks, but they don’t scale and don’t adapt. If a link fails, a statically-routed network keeps sending traffic toward the dead path until a human notices and manually fixes it. OSPF, as a dynamic, link-state routing protocol, automatically:

  • Discovers neighboring routers.
  • Learns the entire network topology (within its area).
  • Calculates the best path to every known destination.
  • Automatically reroutes traffic if a link fails, often within seconds.

OSPF Is a Link-State Protocol — What That Means

Unlike distance-vector protocols (like RIP), which only know “how far” a destination is and via which neighbor, OSPF routers build a complete map of the entire network topology (within their area) by exchanging Link-State Advertisements (LSAs). Every OSPF router in an area ends up with an identical copy of this topology map, called the Link-State Database (LSDB). Each router then independently runs the Dijkstra Shortest Path First (SPF) algorithm against this database to calculate the best path to every destination.

flowchart TD
    A[Router A] -- LSA Exchange --> B[Router B]
    B -- LSA Exchange --> C[Router C]
    A -- LSA Exchange --> C
    A --> D[Each router builds identical LSDB]
    D --> E[Each router runs SPF algorithm independently]
    E --> F[Each router builds its own optimal routing table]

Key OSPF Concepts

TermMeaning
Router ID (RID)A unique 32-bit identifier for each OSPF router, often set manually or derived from the highest loopback/interface IP
AreaA logical grouping of routers; single-area OSPF uses only Area 0 (the “backbone area”)
NeighborAnother OSPF router directly reachable, with which a router has formed an adjacency
AdjacencyA fully synchronized relationship between two neighbors, sharing complete LSDB information
Hello PacketsMulticast packets sent periodically to discover and maintain neighbor relationships
Cost (Metric)OSPF’s path metric, calculated by default as Reference Bandwidth / Interface Bandwidth
DR/BDRDesignated Router / Backup Designated Router — elected on multi-access networks (like Ethernet) to reduce the number of adjacencies needed

How OSPF Neighbors Form Adjacencies

  1. Down — no Hello packets received yet.
  2. Init — a Hello packet has been received, but the router hasn’t seen its own Router ID in the neighbor’s Hello yet.
  3. 2-Way — both routers see each other in each other’s Hello packets; on multi-access networks, DR/BDR election happens here.
  4. ExStart / Exchange — routers begin exchanging database description packets.
  5. Loading — routers request any missing LSAs from each other.
  6. Full — the adjacency is complete; both routers have identical LSDBs.
sequenceDiagram
    participant RA as Router A
    participant RB as Router B
    RA->>RB: Hello (multicast 224.0.0.5)
    RB->>RA: Hello (includes RA's Router ID - now in Init/2-Way)
    RA->>RB: Hello (includes RB's Router ID - 2-Way confirmed)
    RA->>RB: Database Description (ExStart/Exchange)
    RB->>RA: Database Description
    RA->>RB: LSA Request (Loading)
    RB->>RA: LSA Update
    Note over RA,RB: Adjacency reaches FULL state

OSPF Hello and Dead Timers

For two routers to become neighbors, several parameters must match, including the Hello interval (default 10 seconds on broadcast networks) and the Dead interval (default 40 seconds — 4x the Hello interval). If a router doesn’t receive a Hello within the Dead interval, it declares the neighbor down and recalculates routes.

Configuring Single-Area OSPFv2 on Cisco IOS

Basic Configuration

Router(config)# router ospf 1
Router(config-router)# router-id 1.1.1.1
Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router(config-router)# network 10.0.0.0 0.0.0.3 area 0

Breaking this down:

  • router ospf 1 — starts the OSPF process; 1 is the process ID, locally significant only (doesn’t need to match between routers).
  • router-id 1.1.1.1 — manually sets a unique Router ID; without this, IOS picks the highest loopback IP, or if none exists, the highest active physical interface IP.
  • network ... area 0 — this is not advertising a network like a static route; it tells OSPF which interfaces to enable OSPF on, based on matching the interface’s IP against the network/wildcard statement. Any matching interface both participates in OSPF and has its connected subnet advertised.

Example Full Topology Configuration

! Router A
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
interface GigabitEthernet0/0
 ip address 192.168.1.1 255.255.255.0
interface Serial0/0/0
 ip address 10.0.0.1 255.255.255.252

router ospf 1
 router-id 1.1.1.1
 network 1.1.1.1 0.0.0.0 area 0
 network 192.168.1.0 0.0.0.255 area 0
 network 10.0.0.0 0.0.0.3 area 0
! Router B
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
interface GigabitEthernet0/0
 ip address 192.168.2.1 255.255.255.0
interface Serial0/0/0
 ip address 10.0.0.2 255.255.255.252

router ospf 1
 router-id 2.2.2.2
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.2.0 0.0.0.255 area 0
 network 10.0.0.0 0.0.0.3 area 0

Passive Interfaces (Best Practice)

LAN interfaces facing only end hosts (no other routers) should not send unnecessary Hello packets — this reduces overhead and closes a potential security gap (preventing a rogue device from forming an unwanted OSPF adjacency).

Router(config-router)# passive-interface GigabitEthernet0/0

The subnet on Gi0/0 is still advertised into OSPF; the interface simply stops sending/receiving OSPF Hello packets.

Adjusting the Reference Bandwidth (Important on Modern High-Speed Links)

By default, OSPF cost is calculated as 100 Mbps / interface bandwidth, meaning any interface 100 Mbps or faster gets the same minimum cost of 1 — this fails to differentiate between a 1 Gbps and a 10 Gbps link. Adjusting the reference bandwidth fixes this on modern networks:

Router(config-router)# auto-cost reference-bandwidth 10000

This should be configured identically on every router in the OSPF domain to avoid inconsistent path cost calculations.

Verifying OSPF

Check Neighbor Relationships

Router# show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2         1     FULL/  -        00:00:38    10.0.0.2        Serial0/0/0

The state should reach FULL (or 2WAY for DR-other routers on multi-access segments, which is normal and expected).

Check the OSPF Database

Router# show ip ospf database

Check Which Interfaces Are Running OSPF

Router# show ip ospf interface brief
Interface    PID   Area    IP Address/Mask    Cost  State  Nbrs F/C
Gi0/0        1     0       192.168.1.1/24      1     DR     0/0
Se0/0/0      1     0       10.0.0.1/30         64    P2P    1/1

Check the Routing Table for OSPF-Learned Routes

Router# show ip route ospf
O    192.168.2.0/24 [110/65] via 10.0.0.2, 00:12:44, Serial0/0/0

The [110/65] shows the Administrative Distance (110 for OSPF) and the calculated cost (65).

General OSPF Process Verification

Router# show ip protocols

Comparison Table: OSPF vs Static Routing vs RIP

FeatureStatic RoutingRIPOSPF
TypeManualDistance-vectorLink-state
Convergence SpeedN/A (manual)Slow (up to minutes)Fast (seconds)
ScalabilityPoor for large networksPoor (max 15 hops)Excellent
MetricN/AHop countCost (based on bandwidth)
Administrative Distance1 (or 0 for connected)120110
Best ForSmall, stable networksLegacy/small networksEnterprise/campus networks

OSPF on Linux (FRRouting)

Linux servers can run real routing protocols, including OSPF, using FRRouting (FRR) — commonly used in data centers and virtualized network labs.

sudo apt install frr -y
sudo nano /etc/frr/daemons

Enable OSPF daemon:

ospfd=yes
sudo systemctl restart frr
sudo vtysh

Inside the FRR CLI (syntax deliberately mirrors Cisco IOS):

configure terminal
router ospf
 ospf router-id 3.3.3.3
 network 192.168.3.0/24 area 0
end
show ip ospf neighbor

Automating OSPF Neighbor Verification with Python (Netmiko)

from netmiko import ConnectHandler

device = {
    "device_type": "cisco_ios",
    "host": "192.168.1.1",
    "username": "admin",
    "password": "StrongP@ssw0rd!",
}

connection = ConnectHandler(**device)
output = connection.send_command("show ip ospf neighbor")
print(output)

if "FULL" in output:
    print("OSPF adjacency healthy.")
else:
    print("WARNING: OSPF adjacency not FULL - investigate.")

connection.disconnect()

This kind of check is commonly built into automated network health dashboards, flagging any OSPF adjacency that isn’t in the expected FULL (or appropriate 2WAY) state.

Best Practices

  • Always set a manual Router ID rather than relying on automatic selection — automatic selection can change unexpectedly if a loopback or interface is removed, causing unnecessary adjacency resets.
  • Use a Loopback interface for the Router ID source — loopbacks never go down, making the Router ID stable.
  • Configure passive-interface on all LAN-facing interfaces with no other routers, to reduce unnecessary Hello traffic and reduce attack surface.
  • Adjust auto-cost reference-bandwidth consistently across all routers when using interfaces faster than 100 Mbps, to preserve accurate path selection.
  • Use OSPF authentication (MD5 or SHA) to prevent unauthorized devices from forming adjacencies and injecting false routing information.
  • Document your area design even in single-area deployments, since many networks later grow into multi-area OSPF, and a clean starting point simplifies that future migration.

Troubleshooting

SymptomLikely CauseFix
Neighbor stuck in INITOne-way communication (Hello sent, not received back) — often a mismatched ACL or physical issueCheck ACLs, verify Layer 1/2 connectivity
Neighbor stuck in 2WAY (on point-to-point, this is wrong)Mismatched network type expectationsVerify interface types and ip ospf network settings
Neighbor never forms at allMismatched Hello/Dead timers, area number, or subnet maskVerify show ip ospf interface timers and area on both sides match
Route missing from show ip route ospfInterface not included in a network statement, or wrong area configuredVerify network statement wildcard mask and area number
Unexpected path selectionReference bandwidth not adjusted for high-speed linksSet consistent auto-cost reference-bandwidth network-wide
Router ID conflicts (duplicate RID)Two routers coincidentally have the same Router IDManually set unique router-id values

Conclusion

Single-Area OSPFv2 gives networks automatic topology discovery, fast convergence, and scalable dynamic routing — all foundational skills before progressing to multi-area OSPF designs. Understanding the neighbor formation process, correctly using network statements to enable OSPF on the right interfaces, applying passive-interface where appropriate, and knowing the key verification commands (show ip ospf neighbor, show ip route ospf, show ip ospf interface brief) are essential building blocks for any enterprise routing deployment.

References

  1. RFC 2328 – OSPF Version 2 — https://datatracker.ietf.org/doc/html/rfc2328
  2. Cisco OSPF Design Guide — https://www.cisco.com/c/en/us/support/docs/ip/open-shortest-path-first-ospf/7039-1.html
  3. Cisco OSPFv2 Configuration Guide — https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_ospf/configuration/xe-16/iro-xe-16-book.html
  4. FRRouting Documentation — https://docs.frrouting.org/
  5. Netmiko GitHub Repository — https://github.com/ktbyers/netmiko
Total
1
Shares

Leave a Reply

Previous Post
How to configure and verify IPv4 and IPv6 static routing

How to Configure and Verify IPv4 and IPv6 Static Routing

Next Post
Describe the purpose of first hop redundancy protocol

Describe the Purpose of First Hop Redundancy Protocol

Related Posts