Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

Cost · OSPFv2

Direct answer

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.

When to use this

Use it when OSPF prefers the wrong path, or links of different speed get the same cost.

First 30 seconds

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.

Operational verification

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

Evidence · next step

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
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 · Cisco IOS / IOS XE
Key commandip ospf cost <cost>
Scope / prerequisiteUse it when OSPF prefers the wrong path, or links of different speed get the same cost.
Reference · 2
What next?3 suggested next steps
Catalog command links2
Evidence1
On this pageJump to a specific section
Cisco IOS / IOS XE first

Primary Commands

Configuration and operational commands for this Topic.

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 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.

Step 2 Branching troubleshooting Narrow the fault

Path: Networking → OSPFv2 → Cost. Local intent: OSPF cost reference for interface metric calculation, reference bandwidth, manual overrides, path accumulation and the difference between SPF preference and real throughput.

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.

command output · 1
Command lookup Jump straight to Cisco syntax
Key points

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.

Key checks
  • 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.
ReferenceWhy it matters1 section · depth on demand

Internals and state

Local intent: OSPF cost reference for interface metric calculation, reference bandwidth, manual overrides, path accumulation and the difference between SPF preference and real throughput.

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

InterfaceCost with 100 Mb/s referenceCost with 100 Gb/s reference (100000)
100 Mb/s11000
1 Gb/s1 (rounded up)100
10 Gb/s110
40 Gb/s12 (rounded up)
100 Gb/s11

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

RuleReason
Same reference bandwidth on every routerOtherwise path costs aren't comparable and routing can be asymmetric
Use ip ospf cost for deliberate preferenceClear intent; doesn't depend on the bandwidth setting
Be careful with bandwidthIt 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

InterfaceCost with 100 Mbps referenceWith 100 Gbps reference
100 Mbps11000
1 Gbps1100
10 Gbps110
100 Gbps11
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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
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 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%
Embedded reference data

Quick lookup tables

Cost · operational reference

Compact state and interpretation boundaries for fast lookup.

Metric conceptMeaning
Interface costLocal outgoing OSPF metric
Reference bandwidthScale used for derived cost
Accumulated costSum used by SPF to compare paths
Equal costCan permit ECMP
Low OSPF costDoes not mean low latency/utilization
Confirmation

Confirm action

Continue?