Skip to content

Intermediate · Routing: static routes and OSPF · topic 34 of 57 · 35 min

Configuring and verifying single-area OSPF

Explanation

Start OSPF with router ospf 1, set a router ID, then enable it on interfaces with network commands (using wildcard masks) or with ip ospf 1 area 0 on each interface. Make LAN interfaces passive, share a default route with default-information originate, and verify with show ip ospf neighbor, show ip ospf interface brief and show ip route ospf. Most neighbour problems come from mismatched settings.

The goal

Single-area OSPFv2 means every OSPF interface is in area 0. OSPFv2 is the version for IPv4 (OSPFv3 is used for IPv6). You need to do three things on each router: start the process, tell it which interfaces take part, and check that neighbours reach Full and routes appear.

Starting the process and the router ID

output
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
Cisco IOS: 1 is the process ID. It is local to this router: neighbours do not need the same number.

Always set the router ID by hand. Then it never changes by surprise, and show commands are easy to read because R1 is 1.1.1.1, R2 is 2.2.2.2 and so on.

Method 1: network commands with wildcard masks

output
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)# network 10.0.13.1 0.0.0.0 area 0
Cisco IOS: each line enables OSPF on any interface whose IP address falls in the range.

A wildcard mask is the inverse of a subnet mask: 0 bits must match, 1 bits can be anything. For a /24 (255.255.255.0) the wildcard is 0.0.0.255; for a /30 (255.255.255.252) it is 0.0.0.3. A quick way: subtract each octet of the mask from 255. A wildcard of 0.0.0.0 matches exactly one interface address, as in the third line.

Important: the network command does not "advertise a network" directly. It finds interfaces whose IP matches, enables OSPF on them (they send hellos), and OSPF then advertises those interfaces' subnets.

Method 2: on the interface

output
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip ospf 1 area 0
Cisco IOS: enables OSPF process 1 in area 0 on this interface only. Clearer than wildcards, and you see it in the interface config.

Passive interfaces, default route, cost and priority

output
R1(config)# router ospf 1
R1(config-router)# passive-interface GigabitEthernet0/0
R1(config-router)# auto-cost reference-bandwidth 100000
R1(config-router)# default-information originate
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip ospf cost 50
R1(config-if)# ip ospf priority 0
R1(config-if)# ip ospf network point-to-point
Cisco IOS: common extra settings.
  • passive-interface: the LAN subnet is still advertised, but no hellos are sent on that interface. Use it on every LAN facing PCs: no router lives there, and it stops anyone on the LAN from forming a fake neighbour. passive-interface default makes all interfaces passive; then use no passive-interface on the router links.
  • default-information originate: shares this router's default route with all OSPF routers. They see it as O*E2 0.0.0.0/0. The router must already have a default route (for example a static one to the ISP).
  • ip ospf cost: sets the cost of this interface directly, overriding the bandwidth calculation.
  • ip ospf priority: changes the DR election priority on this interface (0 to 255; 0 means never DR).
  • ip ospf network point-to-point: on an Ethernet link with only two routers, skips the DR/BDR election, so the adjacency comes up faster. Set it on both ends.

Verification

output
R1# show ip ospf neighbor
Neighbor ID   Pri   State      Dead Time   Address      Interface
2.2.2.2         1   FULL/DR    00:00:36    10.0.12.2    GigabitEthernet0/1

R1# show ip ospf interface brief
Interface  PID  Area  IP Address/Mask    Cost  State  Nbrs F/C
Gi0/1      1    0     10.0.12.1/30       1     BDR    1/1
Gi0/0      1    0     192.168.1.1/24     1     DR     0/0

R1# show ip route ospf
O     192.168.2.0/24 [110/2] via 10.0.12.2, 00:03:11, GigabitEthernet0/1
O*E2  0.0.0.0/0 [110/1] via 10.0.12.2, 00:03:11, GigabitEthernet0/1
Cisco IOS: neighbours, OSPF interfaces (F/C = full neighbours / total neighbours), and the routes OSPF installed.

show ip protocols summarises it all: the router ID, the networks or interfaces in OSPF, passive interfaces, the reference bandwidth and the AD (Distance 110). Use it first when you take over a router you did not configure.

Why neighbours do not come up

ProblemSymptom and fix
Area mismatchNo neighbour. Both ends of a link must be in the same area.
Hello/dead timers differNo neighbour. Set ip ospf hello-interval and dead-interval the same on both ends.
Different subnet or maskNo neighbour. Both interfaces must be in the same subnet with the same mask.
Duplicate router IDNeighbour fails, log messages about a duplicate. Make every RID unique.
Passive interfaceNo hellos are sent. Remove passive-interface on router-to-router links.
MTU mismatchNeighbour stuck in ExStart or Exchange. Make the interface MTU equal.
Authentication mismatchNo neighbour. Same authentication type and key on both ends.
Careful: Other common mistakes: typing a subnet mask where the wildcard belongs (255.255.255.0 instead of 0.0.0.255), which matches the wrong interfaces; forgetting no shutdown; setting point-to-point on only one end (they may reach Full but routes go wrong); and using default-information originate on a router that has no default route.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Configuring and verifying single-area OSPF · 1/8

Configuring OSPF

In this lesson you will configure OSPF and check that it works.

Prefer a video by a teacher? Find free videos on “ccna single area ospf configuration packet tracer lab” on YouTube ↗

In real life: A hospital group adds a new clinic

A hospital group in Bengaluru runs OSPF area 0 between its main hospital, two clinics and the data centre. When a third clinic opens, the engineer configures only the new router: router-id 5.5.5.5, ip ospf 1 area 0 on the uplink, passive-interface on the LAN. Within seconds every other router has an O route to the new clinic's LAN, and the clinic learns the O*E2 default route to the internet. No other router was touched.

output
Clinic3(config)# router ospf 1
Clinic3(config-router)# router-id 5.5.5.5
Clinic3(config-router)# passive-interface g0/0
Clinic3(config)# interface g0/0
Clinic3(config-if)# ip ospf 1 area 0
Clinic3(config)# interface g0/1
Clinic3(config-if)# ip ospf 1 area 0
Cisco IOS: the whole OSPF configuration of a new branch router.

Practice (0/3 done)

Task 1 · Question

Which command enables OSPF area 0 on an interface with IP 10.0.12.1/30 using the network method?

Task 2 · Code · Python

Two routers face each other on a link. Each interface is a dict like {"router_id": "1.1.1.1", "ip": "10.0.12.1/30", "area": 0, "hello": 10, "dead": 40, "mtu": 1500, "passive": False, "auth": None}. Write neighbor_problems(a, b) that returns a list of reasons they will not become Full neighbours, in this order, using these exact strings: "passive interface" (either side passive), "area mismatch", "subnet mismatch" (different network, use ipaddress), "timer mismatch" (hello or dead differ), "duplicate router ID", "MTU mismatch", "authentication mismatch" (auth values differ). Return [] if all is well.

Task 3 · Practice

Packet Tracer lab. Three 2911 routers in a triangle. R1: G0/0 LAN 192.168.1.1/24, G0/1 10.0.12.1/30 to R2, G0/2 10.0.13.1/30 to R3. R2: G0/0 LAN 192.168.2.1/24, G0/1 10.0.12.2/30, G0/2 10.0.23.1/30 to R3. R3: G0/0 LAN 192.168.3.1/24, G0/1 10.0.13.2/30, G0/2 10.0.23.2/30. Configure single-area OSPF with router IDs 1.1.1.1, 2.2.2.2, 3.3.3.3, passive LAN interfaces and reference bandwidth 100000. Verify, then shut the R1 to R3 link and watch the route to 192.168.3.0/24 move.

Quick quiz

Question 1

1.What does passive-interface g0/0 do under router ospf 1?

Question 2

2.Two OSPF neighbours are stuck in ExStart. What is the most likely cause?

Question 3

3.R1 uses router ospf 1 and R2 uses router ospf 7. Can they become neighbours?

Question 4

4.Which command shares a router's static default route with its OSPF neighbours?

Question 5

5.Which command quickly lists each OSPF interface with its area, cost, state and neighbour count?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does passive-interface g0/0 do under router ospf 1?

Answer: Stops hellos on G0/0 but still advertises its subnet

A passive interface sends no hellos, so no neighbour forms there, but its network is still advertised.

Two OSPF neighbours are stuck in ExStart. What is the most likely cause?

Answer: MTU mismatch

An MTU mismatch blocks the database exchange, so they stay in ExStart or Exchange. An area mismatch stops them before 2-Way.

R1 uses router ospf 1 and R2 uses router ospf 7. Can they become neighbours?

Answer: Yes, the process ID is only locally significant

The process ID is local to each router and is not sent in hellos.

Which command shares a router's static default route with its OSPF neighbours?

Answer: default-information originate

default-information originate, under router ospf, advertises the default route as O*E2.

Which command quickly lists each OSPF interface with its area, cost, state and neighbour count?

Answer: show ip ospf interface brief

show ip ospf interface brief gives one line per OSPF interface with cost, state and full/total neighbours.

What is the default OSPF reference bandwidth on Cisco routers?Related

Answer: 100 Mbps

The default is 100 Mbps, which is why every link of 100 Mbps or faster costs 1.

From OSPF concepts: link state, areas and neighbours

Where does Cisco IOS expect a wildcard mask instead of a subnet mask?Related

Answer: In access-list statements and the OSPF network command

Interfaces take subnet masks. ACLs and OSPF network statements take wildcard masks.

From Subnet masks, prefix length and wildcard masks

The main path is learnt by OSPF. Which AD makes a static route a correct floating backup?Related

Answer: 130

The backup must have a higher AD than OSPF's 110, so 130 works. The others would beat OSPF.

From Static and default routes

What is the default administrative distance of OSPF?Related

Answer: 110

OSPF is 110. EIGRP is 90, RIP is 120.

From How a router forwards: the routing table

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 1 more topic in “Routing: static routes and OSPF” before its exam: First hop redundancy: HSRP, VRRP and GLBP.
  2. Module 7 exam: static routes, OSPF and HSRP · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, IP services: DHCP, DNS, NAT and more. 57 topics left in the course before the final exam.

← Previous: OSPF concepts: link state, areas and neighbours