Pcornel
Networking · Routing › OSPF › OSPFv2

Cost

Cheat sheet · https://pcornel.dk/topic.php?topic=632

Back to the Topic

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.

Remember

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.

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

Commands

ip ospf cost <cost>
Set the OSPF cost of the interface, overriding the bandwidth-based value.
auto-cost reference-bandwidth <mbps>
Set the OSPF reference bandwidth used to calculate interface cost; set the same value on all routers.
ip ospf cost
show ip ospf interface
show ip route ospf

Verify in this order

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

Where it usually breaks

underlay/interface reachability → protocol adjacency/session → received/originated state → policy → best path/RIB → FIB/adjacency → traffic path

Cost · operational reference

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

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=632

Confirmation

Confirm action

Continue?