Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

OSPF Cost & Path Selection Reference

Direct answer

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.

When to use this

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.

First 30 seconds

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.

Operational verification

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
Platform / version applicability
Protocol standard + deployed implementation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformProtocol standard
Key commandshow ip ospf interface brief
Scope / prerequisiteUse it to explain why OSPF chose a path, to make it prefer another, or when fast links of different speeds are treated …
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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.
  • bandwidth was changed to steer OSPF. It also affects QoS and other protocols; use ip ospf cost.
  • Equal-cost paths expected, only one installed. The costs differ slightly, or maximum-paths is 1.
Evidence references

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.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key checks
  • show ip ospf interface brief — the cost of each interface.
  • show ip ospf | include Reference — the reference bandwidth.
  • show ip route <network> — route type, total cost and next hops.
  • show ip ospf border-routers — cost to each ABR and ASBR.
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:

InterfaceDefault costWith reference 100,000 Mb/s
10 Mb/s1010,000
100 Mb/s11,000
1 Gb/s1100
10 Gb/s110

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

OrderRoute typeCode in show ip route
1Intra-areaO
2Inter-areaO IA
3External type 1O E1 (O N1 in an NSSA)
4External type 2O 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

SituationResult
Same prefix as O and O IAO wins, regardless of cost
Same prefix as E1 and E2E1 wins
Two E2 routes with equal metricsLower cost to the ASBR (forward metric) wins
Different reference bandwidths on routersInconsistent costs; suboptimal or asymmetric paths
Summary routesThe 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docProtocol standard + deployed implementation RFC 2328

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
ospf costreference bandwidthauto-costospf metric
Embedded quick reference

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.

Confirmation

Confirm action

Continue?