Routelearn.net
Course menu

Course 9: OSPFLesson 2.1 (3 of 4 in this course)64 of 91 in the CCNA series

Configuring single-area OSPFv2

Network statements and interface configuration, router IDs, passive interfaces, cost and default route advertisement.

Intermediate · 14 min read

Single-area OSPF (Open Shortest Path First) is an OSPF design in which every router interface that runs OSPF belongs to the same area (usually area 0, the backbone). Configuring it means starting an OSPF process, setting a unique router ID, enabling OSPF on the right interfaces, and tuning options such as passive interfaces and cost.

In simple terms: All the routers join one OSPF group and share what they know. You tell each router which of its links take part, and they work out the best paths themselves.

A real-life situation

In the Routing course you connected three sites with static routes. It worked, but every new LAN meant typing routes on every router, in both directions. Now the company is adding a fourth site, and you decide to replace the static routes with OSPF. In this lesson you configure the whole lab: three routers, one area, a default route to the ISP, and costs that make sense on gigabit links.

The OSPF overview showed a short example. This lesson looks at each command properly, the choices you have, and how to check every step.

Gi0/2Gi0/1 .1.2 Gi0/010.0.12.0/30Gi0/1 .1.2 Gi0/010.0.23.0/30Gi0/0Gi0/2Gi0/1ISP203.0.113.1R1RID 1.1.1.1R2RID 2.2.2.2R3RID 3.3.3.3LAN 1192.168.1.0/24LAN 2192.168.2.0/24LAN 3192.168.3.0/24
  1. 1. Neighbours on the two router links. OSPF runs on 10.0.12.0/30 and 10.0.23.0/30. Both links are set to point-to-point: no DR election.
  2. 2. LANs advertised, but no hellos. The three LAN interfaces are in OSPF so their subnets are advertised, but they are passive: no routers live there.
  3. 3. R1 shares its default route. R1 has a static default to the ISP (203.0.113.1) and advertises it into OSPF with default-information originate.
  4. 4. R3 reaches LAN 1 with cost 30. With a reference bandwidth of 10 Gbps, each gigabit interface costs 10: R3 Gi0/0 + R2 Gi0/0 + R1 Gi0/0 = 30.
RouterInterfaceAddressConnects toOSPF role
R1 (1.1.1.1)Gi0/0192.168.1.1/24LAN 1Passive
Gi0/110.0.12.1/30R2Point-to-point neighbour
Gi0/2203.0.113.2/30ISPNot in OSPF
R2 (2.2.2.2)Gi0/010.0.12.2/30R1Point-to-point neighbour
Gi0/110.0.23.1/30R3Point-to-point neighbour
Gi0/2192.168.2.1/24LAN 2Passive
R3 (3.3.3.3)Gi0/010.0.23.2/30R2Point-to-point neighbour
Gi0/1192.168.3.1/24LAN 3Passive

What you are configuring

Single-area OSPFv2 needs only a few decisions:

Start the process
router ospf 1 (the number is local to this router)
Set the router ID
router-id 1.1.1.1, unique on every router
Enable interfaces in area 0
network statements, or ip ospf 1 area 0 on each interface
Make LAN interfaces passive
advertise the subnet, but send no hellos
Tune
reference bandwidth, cost, network type, default route
The order to configure OSPF on each router.

Why it works this way

Enabling OSPF on an interface does two separate things: the router starts sending hellos out of it, and the interface's subnet goes into the router's LSA, so every other router learns it. Usually you want both on router-to-router links, but only the second on LANs full of PCs. Sending hellos there wastes a little effort and, worse, lets anyone who plugs in a device running OSPF try to become a neighbour and inject routes. That is what passive interfaces fix.

Cost is OSPF's metric, the number it adds up to compare paths. It is calculated per outgoing interface as reference bandwidth ÷ interface bandwidth, rounded down and never below 1. With the default 100 Mbps reference, a FastEthernet, gigabit and 10-gigabit link all cost 1, so OSPF cannot tell them apart. Raising the reference (here to 10 000 Mbps) fixes that.

How to configure it on Cisco IOS

Option 1: network statements

network <address> <wildcard-mask> area <area-id>

Router configuration mode. Every interface whose IP address matches the address and wildcard is enabled for OSPF in that area.

A wildcard mask is the inverse of a subnet mask: a 0 bit means "must match" and a 1 bit means "don't care". Subtract the subnet mask from 255.255.255.255 to get it.

StatementMatches
network 192.168.1.0 0.0.0.255 area 0Any interface with an address 192.168.1.0 to 192.168.1.255
network 10.0.12.0 0.0.0.3 area 0Any interface with an address 10.0.12.0 to 10.0.12.3
network 10.0.12.1 0.0.0.0 area 0Only the interface with exactly 10.0.12.1. Very precise.
network 10.0.0.0 0.255.255.255 area 0Every interface in 10.0.0.0/8. Quick, but easy to include too much.
network 0.0.0.0 255.255.255.255 area 0Every interface on the router, including one facing the ISP. Avoid.

The full R1 configuration, using network statements:

ip route 0.0.0.0 0.0.0.0 203.0.113.1 ! interface GigabitEthernet0/1 ip ospf network point-to-point ! router ospf 1 router-id 1.1.1.1 auto-cost reference-bandwidth 10000 passive-interface GigabitEthernet0/0 network 192.168.1.0 0.0.0.255 area 0 network 10.0.12.0 0.0.0.3 area 0 default-information originate

R1. Gi0/2 (203.0.113.2, towards the ISP) matches no network statement, so OSPF never runs there. The static default route is what default-information originate advertises.

Option 2: enabling OSPF on the interface

ip ospf <process-id> area <area-id>

Interface configuration mode. Enables exactly this interface, no wildcards needed. The process is created if it does not exist.

router ospf 1 router-id 2.2.2.2 auto-cost reference-bandwidth 10000 passive-interface GigabitEthernet0/2 ! interface GigabitEthernet0/0 ip ospf 1 area 0 ip ospf network point-to-point ! interface GigabitEthernet0/1 ip ospf 1 area 0 ip ospf network point-to-point ! interface GigabitEthernet0/2 ip ospf 1 area 0

R2. Each interface says for itself which process and area it belongs to.

Passive by default

On a router with many LANs it is safer to make every interface passive and switch hellos on only where a neighbour is expected:

interface GigabitEthernet0/0 ip ospf network point-to-point ! router ospf 1 router-id 3.3.3.3 auto-cost reference-bandwidth 10000 passive-interface default no passive-interface GigabitEthernet0/0 network 10.0.23.2 0.0.0.0 area 0 network 192.168.3.1 0.0.0.0 area 0

R3. Gi0/1 (LAN 3) is passive because of passive-interface default. Only Gi0/0 towards R2 sends hellos. The 0.0.0.0 wildcards match single interface addresses.

Cost and reference bandwidth

router ospf 1 auto-cost reference-bandwidth 10000

The value is in Mbps. 10000 = 10 Gbps, so a 1 Gbps interface costs 10 and a 100 Mbps interface costs 100. IOS reminds you to set the same value on all routers; otherwise their costs are not comparable.

interface GigabitEthernet0/1 ip ospf cost 50

Sets the cost of this one interface directly, overriding the calculation. Cost applies to traffic leaving through this interface only; the router on the other end has its own cost for the reverse direction.

interface GigabitEthernet0/1 bandwidth 100000

The bandwidth command (in kbps) changes the value OSPF divides by, so it changes the cost too. It does not change the real speed of the link.

Cost is decided by (highest priority first)Example
1. ip ospf cost on the interfaceip ospf cost 50 → 50
2. reference bandwidth ÷ bandwidth if set10 000 Mbps ÷ 100 Mbps → 100
3. reference bandwidth ÷ real interface speed10 000 Mbps ÷ 1 000 Mbps → 10

If two paths to the same network have the same total cost, OSPF installs both and shares traffic between them (equal-cost multi-path, up to 4 paths by default, changed with maximum-paths).

Advertising a default route

R1 has a static default route to the ISP. default-information originate under router ospf tells R1 to advertise a default route into OSPF, but only while R1 has a default route in its own routing table. If the ISP link fails and the static route disappears, R1 stops advertising it, which is usually what you want. Adding always advertises it regardless.

How to verify it

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip protocols
*** IP Routing is NSF aware ***

Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 1.1.1.1
  It is an autonomous system boundary router
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    10.0.12.0 0.0.0.3 area 0
    192.168.1.0 0.0.0.255 area 0
  Passive Interface(s):
    GigabitEthernet0/0
  Routing Information Sources:
    Gateway         Distance      Last Update
    2.2.2.2              110      00:04:51
    3.3.3.3              110      00:04:47
  Distance: (default is 110)
The quickest overall check: router ID, the network statements as typed, which interfaces are passive, and which routers you have learned from. R1 is an ASBR (autonomous system boundary router) because it injects the external default route. Interfaces enabled with ip ospf area appear in a separate "Routing on Interfaces Configured Explicitly" list instead.
Example output · based on Cisco documentation; exact format varies by platform and software version
R2#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Gi0/2        1     0               192.168.2.1/24     10    DR    0/0
Gi0/1        1     0               10.0.23.1/30       10    P2P   1/1
Gi0/0        1     0               10.0.12.2/30       10    P2P   1/1
Every OSPF interface, its area, cost (10, thanks to the new reference bandwidth) and state. The point-to-point links show P2P with one Full neighbour each. The LAN shows DR with no neighbours: on a broadcast segment with no other routers, the router is simply DR on its own.
Example output · based on Cisco documentation; exact format varies by platform and software version
R2#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           0   FULL/  -        00:00:34    10.0.23.2       GigabitEthernet0/1
1.1.1.1           0   FULL/  -        00:00:39    10.0.12.1       GigabitEthernet0/0
Example output · based on Cisco documentation; exact format varies by platform and software version
R3#show ip route ospf
Gateway of last resort is 10.0.23.1 to network 0.0.0.0

O*E2  0.0.0.0/0 [110/1] via 10.0.23.1, 00:03:02, GigabitEthernet0/0
      10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O        10.0.12.0/30 [110/20] via 10.0.23.1, 00:03:12, GigabitEthernet0/0
O     192.168.1.0/24 [110/30] via 10.0.23.1, 00:03:12, GigabitEthernet0/0
O     192.168.2.0/24 [110/20] via 10.0.23.1, 00:03:12, GigabitEthernet0/0
[110/30] is administrative distance 110 and cost 30 to LAN 1: three gigabit interfaces at cost 10. The default route is O*E2: learned by OSPF (O), a candidate default (*), external type 2 (E2) with a fixed metric of 1. Codes are explained in Reading the routing table.
show ip ospf interface GigabitEthernet0/1

Full detail for one interface: area, network type, cost, timers, DR/BDR and neighbour count.

What goes wrong and how to troubleshoot it

  • An interface is missing from show ip ospf interface brief. No network statement matches its address (check the wildcard arithmetic), or the ip ospf area command is missing.
  • A LAN is missing from other routers' tables. Same cause: if the interface is not in OSPF, its subnet is not advertised. Making it passive does not stop advertising.
  • No neighbour on a router link. The interface is passive (common after passive-interface default), or the two ends disagree on area, subnet or timers.
  • No default route on R2 and R3. R1 has default-information originate but no default route of its own, for example because the ISP interface is down.
  • Strange path choices. Reference bandwidth set on some routers but not others, so their costs don't add up consistently.

Verifying and troubleshooting OSPF goes through these in a structured way.

Common mistakes

  • Writing a subnet mask instead of a wildcard in the network command, for example network 10.0.12.0 255.255.255.252 area 0.
  • Believing the network command must match the subnet exactly. It only needs to match the interface address.
  • Forgetting that router ospf 1 needs a unique router ID; two routers built from one template end up with the same one.
  • Expecting passive-interface to hide a network. It still advertises the subnet; it only stops hellos.
  • Changing the reference bandwidth on one router only.
  • Thinking ip ospf cost on one end also changes the cost in the other direction.

💡 Exam tip: be quick at matching network statements to interfaces (wildcard maths), and know both ways to enable OSPF. Expect to read show ip route lines like O 192.168.1.0/24 [110/30] and work out the cost from interface costs, to compute cost from reference bandwidth, and to know that passive-interface stops hellos but keeps advertising. default-information originate produces an O*E2 route on the other routers.

Key takeaways

✅ Key takeaways
  • router ospf <id> starts OSPF; the process ID is local, the router ID must be unique.
  • Enable interfaces with network <addr> <wildcard> area 0 or ip ospf <id> area 0.
  • Passive interfaces advertise their subnet but send no hellos; use them on LANs.
  • Cost = reference bandwidth ÷ interface bandwidth; raise the reference on every router.
  • default-information originate shares a default route, shown as O*E2 elsewhere.

Check yourself

Predict · scenario 1

R1 has Gi0/1 10.0.12.1/30 and the command network 10.0.12.0 0.0.0.3 area 0. Which prefix does R1 advertise for that link?

Predict · scenario 2

The reference bandwidth is 10000 Mbps. What is the OSPF cost of a FastEthernet (100 Mbps) interface?

Predict · scenario 3

R2's LAN interface Gi0/2 is configured as passive. What happens to 192.168.2.0/24?

Predict · scenario 4

R3 has passive-interface default and network statements for both interfaces, but no other commands. What happens with R2?

Predict · scenario 5

R1 has default-information originate, but its static default route was removed. What do R2 and R3 see?

FAQ

Does the OSPF network command advertise the network I type?
Not exactly. It selects interfaces: any interface whose IP address matches the address and wildcard is enabled for OSPF in that area. OSPF then advertises each enabled interface's real subnet, with its real mask.
Should I use network statements or ip ospf area on the interface?
Both work and both are on the CCNA exam. The interface command is more explicit and easier to read; network statements are still very common. If both match the same interface, the interface command takes priority.
Why does OSPF give a 1 Gbps and a 10 Gbps link the same cost?
The default reference bandwidth is 100 Mbps, and cost cannot go below 1, so every link of 100 Mbps or faster costs 1. Raise it with auto-cost reference-bandwidth, using the same value on every router.
What does the E2 in O*E2 mean?
The default route was injected into OSPF from outside (by default-information originate), so it is an external route. Type 2 (E2) external routes keep the same metric, 1 by default, no matter how far they travel inside OSPF.