Use it when OSPF prefers the wrong path, or links of different speed get the same cost.
Cost · OSPFv2
OSPF cost is the metric per interface; a route's cost is the sum along the path, and the lowest total wins. By default cost = reference bandwidth / interface bandwidth, with a reference of 100 Mbps.
1. show ip route <prefix> — which next hop and total cost?
2. Expected path costs more? Add up the costs hop by hop (show ip ospf interface brief).
3. Fast links costing 1 → raise the reference bandwidth on all routers.
4. Or set ip ospf cost on the interfaces concerned.
5. Check the route again.
reference bandwidth the same on all routers → interface costs reflect speed or intent → SPF sums cost along each path → lowest total installed → equal totals shared
Compare end-to-end accumulated costs and route metrics on all candidate paths.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
ip ospf cost <cost>Primary Commands
Configuration and operational commands for this Topic.
ip ospf cost <cost>ReferenceSet the OSPF cost of the interface, overriding the bandwidth-based value.
Use when: Override automatically derived OSPF metric to influence path selection.
Quick note: Lower total OSPF path cost is preferred; verify alternate-path behavior too.
Cisco IOS / IOS XE · mixedauto-cost reference-bandwidth <mbps>ReferenceSet the OSPF reference bandwidth used to calculate interface cost; set the same value on all routers.
Use when: Make automatic OSPF costs distinguish higher-speed links consistently across the domain.
Quick note: Reference bandwidth should be a domain design value, not a per-router guess.
Cisco IOS / IOS XE · mixedVerification & 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 Verification and output interpretation Verify boundary
Use show ip ospf interface to read the effective interface cost and confirm reference-bandwidth-related expectations, then use show ip route ospf or route detail to inspect the resulting accumulated OSPF metric for installed destinations. Compare candidate topology paths rather than looking at a single interface in isolation. If two paths are expected to be unequal but both install as ECMP, calculate the full accumulated cost and confirm that high-speed links have not collapsed to the same derived metric. Conversely, an interface with the desired local cost does not show the final route uses that link because SPF can find another lower total path. Correlate route choice with the LSDB/topology when the arithmetic is not obvious.
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, every link of 100 Mbps or faster costs 1 — 1 Gbit/s and 100 Gbit/s look the same. Set auto-cost reference-bandwidth (in Mbps) to the same value on every router, or set ip ospf cost deliberately. Cost is counted on the outgoing interface.
show ip ospf interface brief— cost per interface.show ip route <prefix>— total cost in brackets[110/cost].show ip ospf | include Reference— reference bandwidth.show running-config | include auto-cost|ip ospf cost— what is configured.
ReferenceImportant terms & boundaries4 sections · depth on demand
In depth
OSPF cost: reference bandwidth divided by interface bandwidth
The Catalyst 9300 OSPF guide states that interface cost is the reference bandwidth divided by the interface bandwidth, with a reference bandwidth of 100 Mb/s by default. auto-cost reference-bandwidth changes the reference (in Mb/s), bandwidth changes the interface value used, and an explicit ip ospf cost overrides the calculation.
Why the default reference is a problem
| Interface | Cost with 100 Mb/s reference | Cost with 100 Gb/s reference (100000) |
|---|---|---|
| 100 Mb/s | 1 | 1000 |
| 1 Gb/s | 1 (rounded up) | 100 |
| 10 Gb/s | 1 | 10 |
| 40 Gb/s | 1 | 2 (rounded up) |
| 100 Gb/s | 1 | 1 |
With the default, every link of 100 Mb/s or faster costs 1, so OSPF can't prefer a 10 Gb/s path over a 1 Gb/s path.
R1(config)# router ospf 1
R1(config-router)# auto-cost reference-bandwidth 100000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
R1(config)# interface TenGigabitEthernet1/1/2
R1(config-if)# ip ospf cost 50
R1# show ip ospf interface brief
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Te1/1/1 1 0 10.255.0.1/30 10 P2P 1/1
Te1/1/2 1 0 10.255.0.5/30 50 P2P 1/1
Vl20 1 0 10.20.0.1/24 100 DR 0/0
Rules
| Rule | Reason |
|---|---|
| Same reference bandwidth on every router | Otherwise path costs aren't comparable and routing can be asymmetric |
Use ip ospf cost for deliberate preference | Clear intent; doesn't depend on the bandwidth setting |
Be careful with bandwidth | It also affects QoS and EIGRP calculations |
Path cost
The cost of a route is the sum of the outgoing interface costs along the path. Equal-cost paths are load-shared; the Catalyst 9000 OSPF guide gives maximum-paths a default of 16 for OSPFv3.
Documented example, not captured output.
Quick reference
OSPF cost is the per-interface metric; a route's cost is the sum of outgoing interface costs along the path. On Cisco, cost = reference bandwidth / interface bandwidth, with a minimum of 1.
| Interface | Cost with 100 Mbps reference | With 100 Gbps reference |
|---|---|---|
| 100 Mbps | 1 | 1000 |
| 1 Gbps | 1 | 100 |
| 10 Gbps | 1 | 10 |
| 100 Gbps | 1 | 1 |
router ospf 1
auto-cost reference-bandwidth 100000
interface Gi0/1
ip ospf cost 50
Documented example, not captured output.
Set the same reference bandwidth on every router, or path selection becomes inconsistent.
State model and protocol mechanics
OSPF associates a cost with outgoing interfaces and adds those costs along candidate paths during SPF calculation. Implementations commonly derive interface cost from reference bandwidth divided by interface bandwidth, subject to integer behavior and minimums, unless an explicit ip ospf cost overrides the derived value. If the reference bandwidth is too low relative to modern link speeds, several different high-speed interfaces can collapse to the same cost and lose intended path differentiation. Path selection therefore depends on the metric model, not on real-time congestion. Equal accumulated costs can create equal-cost multipath where the platform and route type permit. The cost visible on an interface is only one component; the routing table reflects the accumulated metric to the destination after SPF has processed the link-state graph.
Limits and common misconceptions
OSPF cost is not a live performance score. A low-cost path can be congested, lossy or high-latency, and OSPF will continue to prefer it unless another mechanism changes the topology or metric. Interface “bandwidth” may be an administrative value rather than a measured link rate, so derived cost inherits that model. Reference bandwidth must be consistent domain-wide for intuitive results, but inconsistency does not necessarily break adjacency—it creates potentially surprising path calculations. A route with the lowest OSPF metric can still lose installation to a route from another source with better administrative distance. Separate OSPF SPF preference from RIB selection and from actual forwarding performance.
ReferenceConfiguration & state1 section · depth on demand
Design and configuration model
Choose one metric strategy and apply it consistently across the OSPF domain. If using derived cost, configure a reference bandwidth high enough to distinguish the fastest relevant links and use the same value on all routers so the graph is interpreted predictably. If using explicit interface costs for traffic-engineering intent, document why those values differ from physical bandwidth and avoid accidental mixtures of local conventions. Changing interface bandwidth for the sole purpose of manipulating OSPF can affect other features that consume the bandwidth setting; an explicit OSPF cost is usually clearer when only OSPF policy should change. Model both primary and backup path totals before applying changes because a small per-interface adjustment can alter multiple destination paths.
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 Routing → OSPF → OSPFv2 → Cost. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc2328.html · confidence 94%Quick lookup tables
Cost · operational reference
Compact state and interpretation boundaries for fast lookup.
| Metric concept | Meaning |
|---|---|
| Interface cost | Local outgoing OSPF metric |
| Reference bandwidth | Scale used for derived cost |
| Accumulated cost | Sum used by SPF to compare paths |
| Equal cost | Can permit ECMP |
| Low OSPF cost | Does not mean low latency/utilization |