Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

Cost · OSPF Fundamentals

Direct answer

OSPF cost is the metric for each interface, added up along a path; the lowest total cost wins. On Cisco the default is reference bandwidth (100 Mbps) divided by interface bandwidth, so set auto-cost reference-bandwidth higher on networks faster than 100 Mbps.

When to use this

Use it when the design or fault is specifically about the per-interface OSPF metric whose cumulative path value drives intra-domain shortest-path selection. Stay on that boundary until configuration intent, live control/security state and the adjacent dependency agree.

First 30 seconds

1. OSPF cost = reference bandwidth / interface bandwidth (default ref 100 Mbps).

2. Set auto-cost reference-bandwidth equal on all routers for fast links.

3. ip ospf cost overrides.

4. Path cost is the sum of outgoing interface costs.

5. Unequal costs cause unexpected paths.

Operational verification

interface bandwidth/ref → cost → SPF sums costs → best path

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 XE · Cisco IOS / IOS XE
Key commandshow ip ospf interface brief
Scope / prerequisiteUse it when the design or fault is specifically about the per-interface OSPF metric whose cumulative path value drives …
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.

7 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 Layered verification and original-test closure Verify boundary

Cost — Read the route metric together with the contributing interface costs, trigger no change unless design intent is clear, and verify both the selected route and a packet test across the intended path.

Step 2 Operational verification and known-good state Verify boundary
show ip ospf interface brief
show ip ospf interface GigabitEthernet0/0 | include Cost
show ip ospf | include Reference
show ip route 10.20.0.0

The brief view lists the cost of every OSPF interface. The interface view states the cost together with the network type. The third shows the reference bandwidth in use, and the route lookup shows the total that SPF arrived at.

Known-good: the reference bandwidth is the same everywhere, costs reflect the real link speeds or the design's explicit values, and the route metric equals the sum along the intended path.

Step 3 Verification & troubleshooting Narrow the fault

1. show ip route <prefix> → the metric, the second number in [110/…].

2. show ip ospf interface brief on each router along the path → the Cost column; add up the outgoing interfaces.

3. Do the same for the alternative path and compare.

4. show ip ospf | include Reference → the reference bandwidth; it must be the same on all routers.

5. Adjust with ip ospf cost where the design calls for it, and check the route again.

Step 4 Observation → implication → next check Narrow the fault

Cost — When the chosen path is unexpected, compare per-interface cost and reference bandwidth first; then confirm topology/LSA visibility. If SPF selects the expected path but forwarding differs, inspect RIB/FIB installation.

Step 5 Failure signatures and troubleshooting branches Narrow the fault
  • Traffic uses a 100 Mb/s link as readily as a 10 Gb/s link. Default reference bandwidth: both cost 1.
  • Forward and return traffic take different paths. A cost was changed on one end of a link only.
  • Costs are inconsistent between routers. The reference bandwidth was changed on some routers and not on others.
  • A tunnel or serial path is never chosen. Its cost comes from a low interface bandwidth.
  • The metric does not match your sum. The cost of the destination network's own interface was left out, or the path is not the one you assumed.
Step 6 When the problem is really fixed Narrow the fault
  • The reference bandwidth is identical on all routers.
  • Each route's metric equals the sum of outgoing costs on the intended path.
  • Paths are the same in both directions, unless asymmetry is intended.
  • Explicit ip ospf cost values are documented.
Step 7 Common mistakes Narrow the fault
  • Different reference bandwidth on different routers.
  • Setting costs manually on some links and forgetting others.
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

Do not infer service health from one command. For Cost, distinguish configured intent, protocol/security state, installed forwarding state and the original workload result.

Key checks
  • show ip ospf interface <interface> — Cost
  • show ip route ospf — total metric
  • show running-config | section router ospf — auto-cost reference-bandwidth
ReferenceWhat it is1 section · depth on demand

What it is

Cost is OSPF's metric. Every OSPF interface has a cost, and the cost of a path is the sum of the costs of the outgoing interfaces along it. The path with the lowest total wins.

ReferenceWhy it matters1 section · depth on demand

Why it matters

Cost is the only thing that decides path choice inside an area. By default it is derived from bandwidth against a reference of 100 Mb/s, which means every link from Fast Ethernet upward costs 1 — in a modern network all links look equal until the reference is changed. And because each router calculates with its own interface costs, the setting has to be consistent across all routers.

ReferenceHow it works1 section · depth on demand

Operational mechanics and ownership

Cost — OSPF interface cost is an input to SPF, not a direct statement of end-to-end latency. The cumulative path metric is derived from the outgoing-interface costs along the selected path. The OSPF process owns cost calculation and SPF; the RIB only receives resulting candidates. A changed interface cost has no forwarding effect until SPF runs and the route is reselected.

ReferenceImportant terms & boundaries4 sections · depth on demand

Key points

  • Default cost = reference bandwidth ÷ interface bandwidth, minimum 1. With the default reference of 100 Mb/s: 10 Mb/s = 10, and 100 Mb/s, 1 Gb/s and 10 Gb/s all = 1.
  • auto-cost reference-bandwidth <Mb/s> under router ospf changes the reference; set the same value on every router. With 100000, 1 Gb/s = 100 and 10 Gb/s = 10.
  • ip ospf cost <n> on an interface overrides the calculation.
  • Only the outgoing interface counts, so each direction is calculated separately.
  • The bandwidth command also changes the calculated cost, but it affects other features as well.
  • Equal totals give equal-cost load sharing.

In depth

OSPF cost: reference bandwidth divided by interface bandwidth

The Catalyst 9300 OSPF guide states that auto-cost is the reference bandwidth divided by the interface bandwidth, that the default reference is 100 Mb/s (changed with auto-cost reference-bandwidth), and that ip ospf cost overrides the calculated value.

InterfaceCost with 100 Mb/s referenceCost with 100 Gb/s reference
100 Mb/s11000
1 Gb/s1100
10 Gb/s110
40 Gb/s12
100 Gb/s11

With the default reference, every link of 100 Mb/s or faster has cost 1, so OSPF can't prefer a 10 Gb/s path over a 1 Gb/s path.

C9300(config)# router ospf 1
C9300(config-router)# auto-cost reference-bandwidth 100000
% OSPF: Reference bandwidth is changed.
        Please ensure reference bandwidth is consistent across all routers.
C9300(config)# interface Te1/1/2
C9300(config-if)# ip ospf cost 50
C9300# 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     10              10.20.0.1/24       100   DR    0/0

Rules

RuleReason
Same reference bandwidth on all routersOtherwise costs are inconsistent and paths become asymmetric
Explicit ip ospf cost on links where the preference mattersIndependent of bandwidth settings
Watch port-channels and SVIsTheir bandwidth (and cost) depends on members or the bandwidth command

Equal-cost multipath

OSPF installs several paths with the same total cost (ECMP). On two equal uplinks, make the costs equal to use both. Make them different to have one primary and one backup.

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 metric of an interface; the best path is the one with the lowest sum of outgoing interface costs. On Cisco the default cost is reference bandwidth (100 Mbps) divided by interface bandwidth, minimum 1.

router ospf 1
 auto-cost reference-bandwidth 400000      ! in Mbps, same on all routers
interface Te1/1/1
 ip ospf cost 10
show ip ospf interface brief

Documented example, not captured output.

With the default reference, 100 Mbps, 1 Gbps and 10 Gbps all cost 1 and OSPF cannot prefer faster links.

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

Mechanics and state ownership

Take three routers in a row with a LAN behind the third. The first router's cost to that LAN is its own outgoing interface cost, plus the second router's outgoing cost, plus the cost of the third router's LAN interface. The costs of the receiving interfaces play no part.

That has two consequences. A cost changed on one end of a link affects only traffic leaving that end, so setting it on one side alone gives different paths in the two directions. And a cost that is derived from bandwidth changes when the bandwidth does — a tunnel interface with its low default bandwidth gets a very high cost, and a port-channel's cost rises when a member link fails.

Changing a cost makes the router issue a new Router LSA, and every router in the area recalculates.

Redistributed routes follow their own rule. An external type 2 route (O E2, the default) keeps the metric it was given at redistribution and ignores the cost inside OSPF; a type 1 route (O E1) adds the internal cost to 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 Routing → OSPF → OSPF Fundamentals → 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

Topic-specific bounded interpretation: known-good state, suspicious signatures and the next technical proof boundary.

BoundaryKnown-good for CostSuspicious signatureNext proof
IntentMatches the per-interface OSPF metric whose cumulative path value drives intra-domain shortest-path selection designConfiguration differs from design/peerCompare effective configuration
Control/security stateStable expected neighbor/database/binding/election stateasymmetric or unexpected path selection from inconsistent reference bandwidth, explicit cost left on one interface, equal costs where differentiation was intended, or metric tuning used to mask an adjacency/forwarding faultInspect protocol/security detail and adjacent state
ForwardingExpected Layer-2 or RIB/FIB/gateway pathControl state exists but traffic path disagreesMAC/ARP/RIB/FIB/CEF proof
ClosureOriginal test passes for explained reasonSymptom moved, was bypassed or protection disabledRegression test
Confirmation

Confirm action

Continue?