show ip route ospf
Shows only the routes learned from OSPF, with their administrative distance, metric and next hop.
Written by a working field network engineer · CCNA, Security+, CySA+
Filters the routing table to routes learned from OSPF. If a network is in the OSPF database but not here, a better source (lower AD) or a more specific prefix is winning.
Example output
R1#show ip route ospf
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is 203.0.113.1 to network 0.0.0.0
O 192.168.20.0/24 [110/2] via 10.0.12.2, 00:14:32, GigabitEthernet0/1Reference output: hand-written in standard Cisco IOS format for this example network, not captured from a device.
Useful variants
show ip route ospf 1
What each column or field means
| Field | Meaning |
|---|---|
O / O IA / O E2 | Intra-area, inter-area (from another area via an ABR) and external (redistributed) OSPF routes. |
[110/2] | OSPF’s administrative distance 110, and the total cost to the destination (here 1 for R1’s Gi0/1 plus 1 for R2’s Gi0/0). |
via 10.0.12.2 | The OSPF neighbor used as next hop. |
When it doesn’t look right
A route is learned by OSPF but a static route is used instead.
Static routes have AD 1 and beat OSPF’s 110. Remove the static route, or make it a floating backup with a higher AD.
No OSPF routes at all.
Check neighbors first. With no FULL adjacency there is nothing to learn.
Related commands
Try it yourself
- OSPF Single-Area Base (Pro)
- Running OSPF and Static Routes Together (Pro)
- Advertising a Forgotten Network Into OSPF (Pro)
- Or build the example network in the free Sandbox
Learn it in the CCNA path
- Scale single-area OSPF across three routers (3. IP Connectivity)
- Originate a default route into OSPF (3. IP Connectivity)
Topic
OSPF — Enable single-area OSPFv2, form neighbor adjacencies, read the neighbor and interface tables and confirm learned routes.