Guide

How to Configure Single-Area OSPF on Cisco (Step by Step)

Single-area OSPF is the first dynamic-routing config most CCNA candidates learn, and the fastest way to get comfortable watching adjacencies form. Here's the whole flow on Cisco IOS — enable the process, advertise your networks into area 0, and confirm it's working.

Step 1 — Enable OSPF and advertise networks

Start the OSPF process and tell it which interfaces to run on. The process ID (1 below) is locally significant — it doesn't have to match between routers. Set a router-id explicitly so the router keeps a stable identity even if an interface goes down.

The network statement uses a wildcard mask (the inverse of the subnet mask) and an area. Every interface whose IP falls inside a network statement runs OSPF and is advertised into that area.

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

Step 2 — Configure the neighbor the same way

Every router in the domain needs the same treatment. On the link between R1 and R2, both sides must be in the SAME area (area 0 here) with matching subnet masks, or the adjacency will never reach FULL.

R2(config)# router ospf 1
R2(config-router)# router-id 2.2.2.2
R2(config-router)# network 10.0.12.0 0.0.0.3 area 0
R2(config-router)# network 192.168.2.0 0.0.0.255 area 0

Step 3 — Verify the adjacency and routes

Confirm the neighbor reached FULL, then check that OSPF-learned routes (marked O) are in the table. show ip ospf interface brief confirms which interfaces are actually running OSPF.

R1# show ip ospf neighbor
R1# show ip route ospf
R1# show ip ospf interface brief

A complete two-router walk-through (with the output to expect)

Concrete addresses make the config click. Picture R1 and R2 joined by a /30 transit link and each fronting its own LAN. The transit is 10.0.12.0/30 on Gi0/0 (R1 = .1, R2 = .2); R1's LAN is 192.168.1.0/24 on Gi0/1 (.1), and R2's LAN is 192.168.2.0/24 on Gi0/1 (.1). Router-ids are 1.1.1.1 and 2.2.2.2. Both LAN and transit subnets go into area 0.

Notice the one nuance the earlier 'Common problems' note hints at: mark the LAN interface passive so OSPF advertises that subnet but never wastes hellos on a segment full of hosts, yet leave the transit interface active, because making the R1-R2 link passive would silently prevent the adjacency from ever forming. That single distinction — advertise the LAN, speak on the transit — is where a lot of first attempts quietly break.

After both routers are configured, verification tells the whole story. The neighbor reaches FULL, and because Gi0/0 is Ethernet (OSPF broadcast network type by default) you'll see a DR/BDR role next to it even though only two routers share the link — R2 wins DR here on the higher router-id. The route to 192.168.2.0/24 arrives with an administrative distance of 110 and a cost of 2 (cost 1 across the Gig transit plus cost 1 for R2's LAN interface), which is exactly what the [110/2] in the table means.

! ----- R1 -----
R1(config)# interface Gi0/0
R1(config-if)#  ip address 10.0.12.1 255.255.255.252
R1(config)# interface Gi0/1
R1(config-if)#  ip address 192.168.1.1 255.255.255.0
R1(config)# router ospf 1
R1(config-router)#  router-id 1.1.1.1
R1(config-router)#  network 10.0.12.0 0.0.0.3 area 0
R1(config-router)#  network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#  passive-interface Gi0/1     ! advertise the LAN, no hellos to hosts

! ----- R2 (mirror image) -----
R2(config)# router ospf 1
R2(config-router)#  router-id 2.2.2.2
R2(config-router)#  network 10.0.12.0 0.0.0.3 area 0
R2(config-router)#  network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#  passive-interface Gi0/1

! ----- Verify on R1 -----
R1# show ip ospf neighbor
Neighbor ID     Pri   State      Dead Time   Address      Interface
2.2.2.2           1   FULL/DR    00:00:35    10.0.12.2    GigabitEthernet0/0

R1# show ip route ospf
      192.168.2.0/24 [110/2] via 10.0.12.2, 00:03:11, GigabitEthernet0/0

How OSPF picks the path: cost, and the reference-bandwidth trap

OSPF has no notion of hop count. Its metric is cost, and the cost of a route is simply the sum of the outgoing interface costs along the path to the destination. Each interface's cost is calculated as a reference bandwidth divided by the interface's bandwidth, and the classic default reference bandwidth on IOS is 100 Mbps (10^8 bps). That formula is why the worked example above showed a cost of 2 — one for each Gigabit-and-above interface the route crossed.

Here's the trap that bites people in modern networks: with the default 100 Mbps reference, any interface at 100 Mbps or faster floors out at cost 1. A GigabitEthernet link, a 10-Gig link, and a 40-Gig link all look identical to OSPF, so it can't prefer the faster path and may load-share across links you'd never want treated as equal. The fix is 'auto-cost reference-bandwidth' set to (at least) your fastest link speed in Mbps — and it must be set to the same value on every router in the domain, or the routers will compute inconsistent costs and choose different paths.

When you need surgical control rather than a domain-wide policy, override a single link with 'ip ospf cost' directly on the interface; a lower number is more preferred. Confirm whatever you set with 'show ip ospf interface', which prints the network type and the cost OSPF is actually using. One thing tuning cost never changes is OSPF's administrative distance — that stays 110, so cost decides between competing OSPF paths, while AD decides whether OSPF loses out to a lower-AD source like a static route or EIGRP.

R1(config)# router ospf 1
R1(config-router)# auto-cost reference-bandwidth 10000
% OSPF: Reference bandwidth is changed.
        Please ensure reference bandwidth is consistent across all routers.
R1(config-router)# exit
R1(config)# interface Gi0/0
R1(config-if)#  ip ospf cost 5           ! pin this link's cost by hand

R1# show ip ospf interface Gi0/0 | include Cost
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 5

Common problems (and the fix)

If the adjacency won't form, check that both interfaces are in the same area, have matching subnet masks, and matching hello/dead timers; that neither interface is passive (passive-interface stops hellos); and that MTU matches on both sides. If routes are missing, make sure the network statement's wildcard mask actually covers the interface's IP.

Frequently asked questions

Can I enable OSPF on an interface without using a network statement?

Yes. On modern IOS you can skip network statements and configure 'ip ospf 1 area 0' directly under the interface, which enables OSPF on exactly that interface with no wildcard-mask math. Both methods are functionally identical once the interface is running, but interface-level config is cleaner because a too-broad wildcard mask can't accidentally pull in an interface you didn't intend to advertise.

Why are my OSPF neighbors stuck in EXSTART or EXCHANGE?

That specific state pair almost always means an MTU mismatch, because OSPF compares interface MTU during database exchange and refuses to advance if the two sides differ. Fix the MTU so both ends match, or as a lab-only workaround add 'ip ospf mtu-ignore' on both interfaces. A neighbor stuck in INIT or 2-WAY is a different problem, usually a one-way hello or DR/BDR issue rather than MTU.

Why does OSPF advertise my loopback as a /32 instead of its configured mask?

By default OSPF treats a loopback as a stub host and advertises it as a /32 host route no matter what mask you set. If you need the real prefix advertised, put 'ip ospf network point-to-point' on the loopback and OSPF will use the configured mask. This is expected behavior, not a bug, and it's a common surprise when you build a /24 loopback to test summarization.

Does OSPF elect a DR and BDR on a point-to-point link between two routers?

No. DR/BDR election only happens on broadcast and non-broadcast multi-access networks, such as an Ethernet segment, to reduce adjacency overhead; a true point-to-point link forms a full adjacency directly with no DR. On a shared Ethernet the DR is chosen by highest OSPF interface priority, then highest router-id, and a priority of 0 removes a router from the election entirely.

How do I advertise a default route to other routers through OSPF?

Configure 'default-information originate' under the OSPF process on the router that owns the default route, typically your internet edge, and OSPF floods a 0.0.0.0/0 default to the rest of the area as an external (E2) route. Add the 'always' keyword if you want it advertised even when that router doesn't currently have its own default route installed, but use 'always' carefully since it can black-hole traffic if the upstream link is actually down.

Practice this on graded Cisco labs

Reading is step one — build OSPF on real Cisco IOS and grade your own config, or try a free sample lab first.