Intermediate · Routing: static routes and OSPF · topic 34 of 57 · 35 min
Configuring and verifying single-area OSPF
Explanation
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
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1Always 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
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 0A 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
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip ospf 1 area 0Passive interfaces, default route, cost and priority
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- 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
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/1show 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
| Problem | Symptom and fix |
|---|---|
| Area mismatch | No neighbour. Both ends of a link must be in the same area. |
| Hello/dead timers differ | No neighbour. Set ip ospf hello-interval and dead-interval the same on both ends. |
| Different subnet or mask | No neighbour. Both interfaces must be in the same subnet with the same mask. |
| Duplicate router ID | Neighbour fails, log messages about a duplicate. Make every RID unique. |
| Passive interface | No hellos are sent. Remove passive-interface on router-to-router links. |
| MTU mismatch | Neighbour stuck in ExStart or Exchange. Make the interface MTU equal. |
| Authentication mismatch | No neighbour. Same authentication type and key on both ends. |
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
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.
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 0Practice (0/3 done)
Which command enables OSPF area 0 on an interface with IP 10.0.12.1/30 using the network method?
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.
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- First hop redundancy: HSRP, VRRP and GLBPRouting: static routes and OSPF · same module
- Troubleshooting tools and common faultsTroubleshooting and the CCNA exam
- Access control lists (ACLs)Network security
- Network basics: IP addresses, routes, DNS and the ip commandLinux and Red Hat (RHCSA to RHCE) · Software and networking
- Validating addresses and checking the same subnetIPv4 addressing
- NAT and PATIP services: DHCP, DNS, NAT and more
Questions people ask about this
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.
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.
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.
What is the default administrative distance of OSPF?Related
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 more topic in “Routing: static routes and OSPF” before its exam: First hop redundancy: HSRP, VRRP and GLBP.
- Module 7 exam: static routes, OSPF and HSRP · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, IP services: DHCP, DNS, NAT and more. 57 topics left in the course before the final exam.