Use it to explain why OSPF chose a path, to make it prefer another, or when fast links of different speeds are treated as equal.
OSPF Cost & Path Selection Reference
OSPF picks the path with the lowest total cost. Each interface's cost is the reference bandwidth divided by the interface bandwidth, and a path's cost is the sum of the outgoing interfaces along it.
1. show ip route <network> — note the type and the cost in [110/…].
2. Add up the interface costs along the path you expected.
3. Costs do not add up → reference bandwidth differs between routers.
4. A higher-cost path wins → it is a preferred route type.
5. To steer: ip ospf cost on the interface.
reference bandwidth equal on all routers → interface costs as designed → path cost = sum of outgoing interface costs → route type compared first, then cost → equal costs installed together
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
show ip ospf interface briefVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational verification Verify boundary
show ip ospf interface brief
show ip ospf | include Reference
show ip route 10.20.0.0
show ip ospf border-routers
The brief interface view lists the cost of each interface. show ip ospf shows the reference bandwidth. The route shows the type, the total cost — the second number in [110/…] — and the next hops. border-routers gives the cost to each ABR and ASBR.
To explain a route, add the interface costs along the expected path and compare with the cost shown.
Known-good: the reference bandwidth is the same on all routers, and the installed cost equals the sum along the intended path.
Step 2 Typical faults & boundaries Narrow the fault
- A slow link is used alongside a fast one. Both have cost 1 under the default reference bandwidth.
- Costs do not add up between routers. The reference bandwidth differs; some routers were not changed.
- A longer-cost path wins. It is a preferred route type — intra-area over inter-area, for instance.
- Traffic goes out one way and returns another. Costs are set per direction and differ at the two ends.
bandwidthwas changed to steer OSPF. It also affects QoS and other protocols; useip ospf cost.- Equal-cost paths expected, only one installed. The costs differ slightly, or
maximum-pathsis 1.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
With the default reference of 100 Mb/s, every interface of 100 Mb/s or more has cost 1; raise it with auto-cost reference-bandwidth on all routers alike. Route type is compared before cost: intra-area beats inter-area beats E1 beats E2.
ReferenceWhat it is1 section · depth on demand
Mechanics & mental model
OSPF chooses paths by cost. Each interface has a cost, derived from its bandwidth unless set by hand, and the cost of a path is the sum of the costs of the outgoing interfaces along it. The lowest total wins.
ReferenceWhy it matters1 section · depth on demand
Why it matters operationally
Two things regularly surprise. With default settings every interface of 100 Mb/s or faster has the same cost, so OSPF cannot tell a 10 Gb/s link from a Fast Ethernet one. And cost is not the first thing compared: the type of route comes before it.
ReferenceHow it works1 section · depth on demand
How it works
Interface cost = reference bandwidth ÷ interface bandwidth, rounded down, with a minimum of 1. The default reference is 100 Mb/s:
| Interface | Default cost | With reference 100,000 Mb/s |
|---|---|---|
| 10 Mb/s | 10 | 10,000 |
| 100 Mb/s | 1 | 1,000 |
| 1 Gb/s | 1 | 100 |
| 10 Gb/s | 1 | 10 |
auto-cost reference-bandwidth <Mb/s> under the OSPF process raises the reference. It must be set to the same value on every router, or costs are no longer comparable. ip ospf cost <n> on an interface overrides the calculation.
Path cost adds the cost of each outgoing interface from the router to the destination. Costs are per direction, so the path back can differ.
Route type comes first. For the same prefix OSPF prefers, in order: intra-area (O), inter-area (O IA), external type 1 (E1), external type 2 (E2). An intra-area path with cost 500 beats an inter-area path with cost 10.
Among routes of the same type the lowest cost wins. For E2 routes the cost shown is only the external metric; if two E2 routes have equal metrics, the one with the lower cost to the ASBR is chosen.
Paths with equal cost are installed together — four by default — and share the traffic.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
OSPF picks routes by type first, then by cost
Route type is compared before cost, so a more expensive path of a preferred type still wins.
Route-type preference
| Order | Route type | Code in show ip route |
|---|---|---|
| 1 | Intra-area | O |
| 2 | Inter-area | O IA |
| 3 | External type 1 | O E1 (O N1 in an NSSA) |
| 4 | External type 2 | O E2 (O N2 in an NSSA) |
An intra-area path is preferred over an inter-area path to the same prefix, even if the inter-area path has a lower cost. RFC 2328 also states that E1 paths always win over E2 paths.
Cost
The Catalyst 9300 OSPF guide gives auto-cost as reference bandwidth divided by interface bandwidth, with a default reference of 100 Mb/s (auto-cost reference-bandwidth), overridden per interface with ip ospf cost.
C9300(config)# router ospf 1
C9300(config-router)# auto-cost reference-bandwidth 100000
C9300(config-router)# maximum-paths 4
C9300# show ip route 10.30.0.0
Routing entry for 10.30.0.0/16
Known via "ospf 1", distance 110, metric 20, type inter area
Routing Descriptor Blocks:
* 10.255.0.2, from 10.0.0.12, via TenGigabitEthernet1/1/1
* 10.255.0.6, from 10.0.0.13, via TenGigabitEthernet1/1/2
C9300# show ip ospf border-routes
Equal-cost paths
With equal total cost, OSPF installs up to maximum-paths routes (the IOS default is commonly 4). Traffic is load-shared by CEF per flow.
Tie-breaks and surprises
| Situation | Result |
|---|---|
| Same prefix as O and O IA | O wins, regardless of cost |
| Same prefix as E1 and E2 | E1 wins |
| Two E2 routes with equal metrics | Lower cost to the ASBR (forward metric) wins |
| Different reference bandwidths on routers | Inconsistent costs; suboptimal or asymmetric paths |
| Summary routes | The ABR advertises the summary with a metric derived from its component routes |
Distance
OSPF's administrative distance is 110 for all route types by default. It only matters against other protocols. distance ospf intra-area|inter-area|external changes it per type, for migrations.
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Network & Protocols → OSPF Cost & Path Selection Reference. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc2328.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Operational notes
Former standalone Cheat Sheet content now lives directly inside the Topic where it belongs.
OSPF Cost Fast Check
Path-cost verification.
show ip ospf interface <if> → interface cost
show ip ospf → reference bandwidth
show ip route <prefix> → selected route / total metric
show ip cef <prefix> → forwarding
Keep reference bandwidth consistent across the domain.