OSPF (Open Shortest Path First) is an open-standard, link-state routing protocol that routers use inside one network. Each router shares the state of its links, builds the same map of its area, and runs the shortest path first (SPF) algorithm to pick the lowest-cost path. On the CCNA 200-301, you configure and troubleshoot single-area OSPFv2.
Practice CCNA questions free (no sign-up)
What is OSPF and how does the protocol work?
OSPF is an interior gateway protocol (IGP): it routes inside one organization. OSPFv2 for IPv4 is defined in RFC 2328, and OSPFv3 for IPv6 in RFC 5340. As a link-state protocol, it shares link information, not routing tables, and every router computes its own routes.
Key facts from RFC 2328:
- OSPF runs directly over IP as protocol 89, not over TCP or UDP.
- Routers send Hellos to multicast 224.0.0.5 (all OSPF routers); 224.0.0.6 reaches the DR and BDR.
- Routers are grouped into areas. Area 0 is the backbone, and other areas attach to it.
- The metric is cost, based on interface bandwidth. Cisco gives OSPF routes an administrative distance of 110.
Is OSPF on the CCNA exam?
Yes. Cisco CCNA 200-301 v1.1 exam topic 3.4 is "Configure and verify single area OSPFv2", inside IP Connectivity, the largest domain at 25% of the exam, according to the CCNA exam topics. It lists four sub-topics: neighbor adjacencies, point-to-point, broadcast (DR/BDR selection), and router ID. Multi-area design is out of scope. Candidates report OSPF as a common lab topic; our CCNA labs guide explains the lab format.
As of November 2026, Cisco's CCNA v2.0 is scheduled to replace v1.1 on February 3, 2027. Check the CCNA v2.0 exam topics page before you book.
OSPF vs EIGRP vs BGP: what is the difference?
OSPF and EIGRP route inside one organization; BGP routes between organizations and carries internet routes. OSPF is an open link-state standard, EIGRP is Cisco's distance-vector protocol, and BGP is a path-vector protocol over TCP.
| Feature | BGP | EIGRP | OSPF |
|---|---|---|---|
| Role | Between autonomous systems | Interior (IGP) | Interior (IGP) |
| Type | Path-vector | Distance-vector | Link-state |
| Specification | RFC 4271, open standard | RFC 7868, informational (Cisco) | RFC 2328, open standard |
| Transport | TCP port 179 | IP protocol 88 | IP protocol 89 |
| Path choice | Path attributes such as AS_PATH | Bandwidth and delay by default | Lowest total cost |
| Cisco admin distance | 20 eBGP, 200 iBGP | 90 internal, 170 external | 110 |
Distances are from Cisco's "Understand Administrative Distance". Of the three, only OSPF has a configuration topic on CCNA 200-301 v1.1.
OSPF vs EIGRP
EIGRP was Cisco-only until Cisco published it as RFC 7868 in 2016, an informational RFC rather than a standard. OSPF runs on any vendor's routers. If a router learns the same prefix from both, internal EIGRP (90) beats OSPF (110).
OSPF vs BGP
OSPF finds neighbors automatically with Hellos. BGP peers are configured by hand and talk over TCP port 179, per RFC 4271. Many networks run both: OSPF inside, BGP at the edge toward ISPs.
What are the OSPF neighbor states?
OSPF neighbors move through seven states, from Down to FULL, as they exchange Hellos and then synchronize their link-state databases. FULL needs matching Hello settings. Cisco's tech note "Understand OSPF Neighbor States" lists the states in order:
| State | What it means | Normal to stay here? |
|---|---|---|
| Down | No Hellos heard from this neighbor yet | No |
| Init | A Hello arrived, but it does not list my router ID | No |
| 2-WAY | Each router sees its own ID in the other's Hello | Yes, between two DROTHERs on Ethernet |
| EXSTART | Routers agree who leads the database exchange | No |
| EXCHANGE | Routers swap database summaries | No |
| LOADING | Routers request the LSAs they are missing | No |
| FULL | Databases match; routes can be calculated | Yes, this is the goal |
For two routers to pass 2-WAY, these must match on the link. RFC 2328 sections 8.2 and 10.5 define the checks:
- Area ID (both ends in area 0)
- Hello and Dead intervals (10 and 40 seconds by default on Ethernet and point-to-point links)
- Subnet and mask, on broadcast links
- Authentication, if configured
- Stub area flag
After 2-WAY, an MTU mismatch stalls neighbors in EXSTART or EXCHANGE.
How are the DR and BDR elected?
On a broadcast segment such as Ethernet, OSPF elects a designated router (DR) and a backup (BDR). The interface with the highest OSPF priority wins, and the highest router ID breaks a tie. Every other router is a DROTHER and goes FULL only with the DR and BDR.
- Priority is set per interface with
ip ospf priority. The range is 0 to 255 and the default is 1. - Priority 0 means the router can never become DR or BDR on that segment.
- The election is per segment, not per area.
- The election does not preempt. A better router that comes up later does not take over. To force a new election, run
clear ip ospf processon the current DR. - Point-to-point links do not elect a DR at all.
Cisco's note on neighbors stuck in two-way state confirms that 2-WAY between DROTHERs is normal.
How does OSPF choose the router ID?
Cisco IOS picks the OSPF router ID in this order: the router-id command first, then the highest IP address on an up loopback, then the highest IP address on an up physical interface. It must be unique in the domain, and it is chosen when the process starts. Change it later and IOS tells you:
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
% OSPF: Reload or use "clear ip ospf process" command, for this to take effect
Run clear ip ospf process in privileged EXEC mode. Until then, show ip ospf still shows the old ID, a favorite exam trap.
How is OSPF cost calculated?
OSPF cost equals the reference bandwidth divided by the interface bandwidth, with a minimum of 1. Cisco IOS uses a 100 Mbps reference bandwidth by default. A route's metric is the sum of the costs of the outgoing interfaces along the path, and the lowest total wins.
| Interface | Bandwidth | Cost at 100 Mbps reference | Cost at 10,000 Mbps reference |
|---|---|---|---|
| Serial (T1) | 1.544 Mbps | 64 | 6476 |
| FastEthernet | 100 Mbps | 1 | 100 |
| GigabitEthernet | 1,000 Mbps | 1 | 10 |
At the default, FastEthernet and Gigabit both cost 1. Fix it with auto-cost reference-bandwidth (in Mbps) on every router:
R1(config-router)# auto-cost reference-bandwidth 10000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
Or set one link with ip ospf cost 50. The Cisco IOS XE "Configuring OSPF" guide documents these commands.
OSPF configuration: network command or interface command?
Both work and both appear on the CCNA. The network command matches interface addresses with a wildcard mask; ip ospf 1 area 0, entered on an interface, enables that one interface. Pick one style per router.
A network statement does not advertise the network you typed. It enables OSPF on every interface whose address falls in the range, and advertises that interface's real subnet. Cisco documents the interface method in "Enabling OSPFv2 on an Interface Basis".
| Statement | What it matches |
|---|---|
network 10.0.12.0 0.0.0.255 area 0 |
Any interface in 10.0.12.0–10.0.12.255 |
network 10.0.12.1 0.0.0.0 area 0 |
Only the interface with exactly 10.0.12.1 |
network 0.0.0.0 255.255.255.255 area 0 |
Every interface on the router |
ip ospf 1 area 0 (interface mode) |
Only the interface you are on |
Wildcard rule: subtract each mask octet from 255, so 255.255.255.252 becomes 0.0.0.3. For more practice, see the wildcard section of our CCNA subnetting guide.
What does passive-interface do in OSPF?
A passive interface still has its subnet advertised in OSPF, but the router sends no Hellos on it, so it never forms a neighbor there. Use it on LAN ports that face PCs.
Use passive-interface GigabitEthernet0/2 per port, or passive-interface default plus no passive-interface on router links. Cisco describes the second style in "Default Passive Interfaces". The classic trap is a passive router link, which kills that adjacency.
How do you advertise a default route in OSPF?
Configure a default route on the edge router, then enter default-information originate under router ospf. Other routers learn it as O*E2 0.0.0.0/0. Without the always keyword, the edge router advertises the default only while it has a default route in its own routing table.
Cisco explains this in "Identify how OSPF Injects a Default Route in a Normal Area".
OSPF configuration example: three routers, one area
This original topology is the size of a CCNA lab. R1–R2 is Ethernet, R1–R3 a point-to-point /30, and R2 the internet edge.
| Router | Router ID | Links |
|---|---|---|
| R1 | 1.1.1.1 (Lo0) | Gi0/0 10.0.12.1/24 to R2, Gi0/1 10.0.13.1/30 to R3, Gi0/2 192.168.1.1/24 LAN |
| R2 | 2.2.2.2 (Lo0) | Gi0/0 10.0.12.2/24 to R1, Gi0/1 203.0.113.2/30 to ISP |
| R3 | 3.3.3.3 (Lo0) | Gi0/1 10.0.13.2/30 to R1, Gi0/2 192.168.3.1/24 LAN |
Interface addresses are preset; R2's Loopback0 matches R1's style. R1 uses network statements. R2 gets priority 100 so it becomes DR; set priorities before OSPF comes up, because the election does not preempt.
R1(config)# interface Loopback0
R1(config-if)# ip address 1.1.1.1 255.255.255.255
R1(config-if)# interface GigabitEthernet0/1
R1(config-if)# ip ospf network point-to-point
R1(config-if)# exit
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# auto-cost reference-bandwidth 10000
R1(config-router)# passive-interface GigabitEthernet0/2
R1(config-router)# network 1.1.1.1 0.0.0.0 area 0
R1(config-router)# network 10.0.12.0 0.0.0.255 area 0
R1(config-router)# network 10.0.13.0 0.0.0.3 area 0
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
R2 keeps its ISP link out of OSPF and originates the default route.
R2(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1
R2(config)# interface GigabitEthernet0/0
R2(config-if)# ip ospf priority 100
R2(config-if)# exit
R2(config)# router ospf 1
R2(config-router)# router-id 2.2.2.2
R2(config-router)# auto-cost reference-bandwidth 10000
R2(config-router)# network 2.2.2.2 0.0.0.0 area 0
R2(config-router)# network 10.0.12.0 0.0.0.255 area 0
R2(config-router)# default-information originate
R3 uses the interface method, passive everywhere except the link to R1.
R3(config)# router ospf 1
R3(config-router)# router-id 3.3.3.3
R3(config-router)# auto-cost reference-bandwidth 10000
R3(config-router)# passive-interface default
R3(config-router)# no passive-interface GigabitEthernet0/1
R3(config-router)# exit
R3(config)# interface Loopback0
R3(config-if)# ip address 3.3.3.3 255.255.255.255
R3(config-if)# ip ospf 1 area 0
R3(config-if)# interface GigabitEthernet0/1
R3(config-if)# ip ospf network point-to-point
R3(config-if)# ip ospf 1 area 0
R3(config-if)# interface GigabitEthernet0/2
R3(config-if)# ip ospf 1 area 0
When an adjacency comes up, IOS logs it:
%OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on GigabitEthernet0/0 from LOADING to FULL, Loading Done
How do you troubleshoot OSPF with show commands?
Check neighbors, then interfaces, then routes: show ip ospf neighbor proves adjacency, show ip ospf interface shows area, cost and DR role, and show ip route ospf proves routes arrived.
show ip ospf neighbor
R1# show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:35 10.0.13.2 GigabitEthernet0/1
2.2.2.2 100 FULL/DR 00:00:31 10.0.12.2 GigabitEthernet0/0
The point-to-point neighbor shows FULL/ - because that link has no DR. A missing neighbor means mismatched Hello settings or a passive interface. A neighbor stuck in EXSTART or EXCHANGE points to MTU, per "Why Are OSPF Neighbors Stuck in Exstart/Exchange State?".
show ip ospf interface
R1# show ip ospf interface brief
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Lo0 1 0 1.1.1.1/32 1 LOOP 0/0
Gi0/2 1 0 192.168.1.1/24 10 DR 0/0
Gi0/1 1 0 10.0.13.1/30 10 P2P 1/1
Gi0/0 1 0 10.0.12.1/24 10 BDR 1/1
Cost 10 on Gigabit proves the new reference bandwidth took effect. Gi0/2 is DR of an empty passive LAN, which is expected. Without brief, the output adds timers (Hello 10, Dead 40), Attached via Network Statement (R3 shows Interface Enable), and No Hellos (Passive interface) on passive ports. Cisco explains each field in "What Does the show ip ospf interface Command Reveal?".
show ip route ospf
R1# show ip route ospf
Codes: ... O - OSPF, E2 - OSPF external type 2, * - candidate default
<output omitted>
Gateway of last resort is 10.0.12.2 to network 0.0.0.0
O*E2 0.0.0.0/0 [110/1] via 10.0.12.2, 00:04:18, GigabitEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/11] via 10.0.12.2, 00:04:18, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/11] via 10.0.13.2, 00:04:28, GigabitEthernet0/1
O 192.168.3.0/24 [110/20] via 10.0.13.2, 00:04:28, GigabitEthernet0/1
In [110/20], 110 is OSPF's administrative distance and 20 is the cost: R1's Gi0/1 (10) plus R3's Gi0/2 (10). The default route is E2 with metric 1, and E2 cost does not grow along the path.
Practice CCNA questions free (no sign-up)
What are the most common OSPF lab mistakes?
Most failed OSPF labs come from small errors with clear symptoms.
| Mistake | Symptom | Fix |
|---|---|---|
Subnet mask in network (255.255.255.0) |
Wrong or no interfaces in OSPF | Use the wildcard, 0.0.0.255 |
| Router-facing link made passive | Neighbor never appears | no passive-interface Gi0/0 |
| Hello or Dead timers differ | Neighbor never appears | Match ip ospf hello-interval on both ends |
| Different area numbers on one link | Neighbor never appears | Put both ends in area 0 |
router-id changed, process not reset |
show ip ospf shows old ID |
clear ip ospf process |
| MTU differs on the two ends | Stuck in EXSTART or EXCHANGE | Match the interface MTU |
| Priority 0 on every router of a segment | All neighbors stuck in 2-WAY | Give at least one router priority 1 or higher |
| Reference bandwidth set on one router only | Unexpected path choice | Same auto-cost value everywhere |
default-information originate with no default route |
No O*E2 on other routers |
Add the static default on the edge |
How should you practice OSPF for the exam?
Build the topology above in Packet Tracer, verify it, then break one row of the mistakes table at a time and fix it from show output only. Repeat until you can predict the DR, router ID and costs before you look.
Then drill timed questions with exhibits like these. Start with the free CCNA quiz, read the CCNA exam guide for the full blueprint, and slot OSPF into weeks 3–4, the routing block, of the CCNA 200-301 study plan. For how simulation and exhibit questions are scored, see CCNA question types.
Get the CCNA Exam Pass Practice CCNA questions free (no sign-up)
Sources
- Cisco, CCNA 200-301 exam topics: topic 3.4 and the 25% IP Connectivity weight.
- Cisco, CCNA v2.0 exam topics: version change dates.
- IETF, RFC 2328, OSPF Version 2: link-state design, IP protocol 89, multicast addresses, areas, Hello checks, priority and DR election.
- IETF, RFC 5340, OSPF for IPv6: OSPFv3.
- IETF, RFC 7868, Cisco's Enhanced Interior Gateway Routing Protocol (EIGRP): informational status, IP protocol 88, default metric.
- IETF, RFC 4271, A Border Gateway Protocol 4 (BGP-4): path attributes and TCP port 179.
- Cisco, Understand Administrative Distance: default distances for OSPF, EIGRP and BGP.
- Cisco, IP Routing Configuration Guide, Cisco IOS XE 17.12.x: Configuring OSPF.
- Cisco, Enabling OSPFv2 on an Interface Basis.
- Cisco, Default Passive Interfaces.
- Cisco tech notes: Understand OSPF Neighbor States, neighbors stuck in two-way, stuck in Exstart/Exchange, show ip ospf interface, default route injection.
- Lab topic frequency: reported by candidates in 2026, as summarized in our CCNA labs guide; not a Cisco statement.
- All topologies, configurations and exhibits are original.
Frequently asked questions
What is OSPF?
OSPF (Open Shortest Path First) is an open-standard, link-state interior routing protocol defined in RFC 2328. Each router learns the full map of its area and runs the shortest path first algorithm to choose the lowest-cost path to every network.
What is the difference between OSPF and BGP?
OSPF routes inside one organization and finds neighbors automatically with Hello packets. BGP routes between autonomous systems, such as ISPs, over manually configured TCP sessions on port 179, and chooses paths by attributes such as AS_PATH.
What is the difference between OSPF and EIGRP?
Both route inside one organization. OSPF is a link-state open standard that uses a bandwidth-based cost. EIGRP is Cisco's distance-vector protocol, published as informational RFC 7868, that uses bandwidth and delay by default. Cisco gives internal EIGRP an administrative distance of 90 and OSPF 110.
How is OSPF cost calculated?
Cost is the reference bandwidth divided by the interface bandwidth, with a minimum of 1. Cisco IOS uses 100 Mbps by default, so FastEthernet and Gigabit both cost 1 until you raise auto-cost reference-bandwidth on every router.
What are the OSPF neighbor states?
Down, Init, 2-WAY, EXSTART, EXCHANGE, LOADING and FULL. FULL is the goal. 2-WAY is normal between two DROTHER routers on Ethernet, while a neighbor stuck in EXSTART or EXCHANGE usually points to an MTU mismatch.
What does passive-interface do in OSPF?
It stops OSPF Hellos on that interface, so no neighbor forms there, but the interface's subnet is still advertised. Use it on LAN ports that face PCs, never on a link to another router.
How do you configure OSPF on a Cisco router?
Enter router ospf 1, set a router-id, then enable interfaces with network statements and wildcard masks or with ip ospf 1 area 0 on each interface. Verify with show ip ospf neighbor and show ip route ospf.
Is OSPF on the CCNA 200-301 exam?
Yes. Exam topic 3.4 of CCNA 200-301 v1.1 is "Configure and verify single area OSPFv2". It lists neighbor adjacencies, point-to-point, broadcast DR/BDR selection and router ID.
Reading is step one. Practice is step two.
Put this plan to work: take the free CCNA practice quiz — same domains, same pressure, instant feedback.
Take the free CCNA quiz or read the full CCNA exam guide