OSPF Cost Calculator

Calculate the OSPF interface cost from any reference bandwidth and interface speed. Generate ready-to-paste Cisco IOS commands and understand why the 100 Mbps default is broken.

Cost Reference Table

Cells highlighted in yellow have cost = 1, meaning OSPF cannot differentiate that link from any faster interface at that reference bandwidth.

InterfaceRef: 100 MbpsRef: 1 GbpsRef: 10 GbpsRef: 100 Gbps
T1 (1.544 Mbps)65648647764767
E1 (2.048 Mbps)49489488348829
T3 (44.736 Mbps)3232242236
Ethernet (10 Mbps)10100100010000
FastEthernet (100 Mbps)1101001000
OC-3 (155 Mbps)1765646
GigabitEthernet (1 Gbps)1110100
10GigabitEthernet (10 Gbps)11110
100GigabitEthernet (100 Gbps)1111

Published: April 2026 | Author: TriVolt Editorial Team | Last Updated: April 2026

The OSPF Cost Formula

OSPF (Open Shortest Path First) uses a dimensionless metric called cost to determine the best path through a network. Unlike RIP, which simply counts hops, OSPF cost is derived from interface bandwidth — making it a far more accurate reflection of real network performance.

The formula is deceptively simple:

cost = max(1, ⌈ reference bandwidth / interface bandwidth ⌉)

Both values in the same unit (bits per second). Minimum cost is always 1.

The ceiling function (⌈ ⌉) means fractional results round up. The minimum value of 1 is enforced by the protocol — no interface can have a cost of zero. When you add up the costs along every link in a path, the path with the lowest total cost wins.

By default, Cisco IOS sets the reference bandwidth to 100 Mbps (100,000,000 bps). This was a reasonable choice in the early 1990s, when FastEthernet was the fastest link most networks would ever deploy. It is no longer reasonable.

Why the 100 Mbps Default Is Broken

The 100 Mbps reference bandwidth creates a silent, dangerous misconfiguration on any network that runs links faster than 100 Mbps — which today means virtually every enterprise and service-provider environment.

Here is why: with a 100 Mbps reference bandwidth, the cost formula produces:

  • FastEthernet (100 Mbps): cost = max(1, ⌈100 / 100⌉) = 1
  • GigabitEthernet (1 Gbps): cost = max(1, ⌈100 / 1000⌉) = max(1, 0.1) = 1
  • 10GigabitEthernet (10 Gbps): cost = max(1, ⌈100 / 10000⌉) = max(1, 0.01) = 1

All three interfaces get the same cost of 1. OSPF is completely blind to the tenfold and hundredfold speed differences between them. The SPF algorithm will treat a path through a 100 Mbps link as equally attractive as a path through a 10 Gbps link — and may route production traffic over the slower path if it happens to have a slightly shorter hop count.

This is not a theoretical problem. It is a common source of suboptimal routing in real networks, and it is almost always caused by administrators leaving the OSPF reference bandwidth at its default value of 100 Mbps.

Cisco Best Practice: Set the Reference Bandwidth Explicitly

Cisco's official recommendation is to set the OSPF reference bandwidth to match or exceed the fastest link in your network. The command is applied globally to the OSPF process on every router — all routers in the same OSPF domain must use the same value or you will get routing inconsistencies.

For networks with 1 Gbps links (common enterprise):

router ospf 1
 auto-cost reference-bandwidth 1000

For networks with 10 Gbps links (current best practice):

router ospf 1
 auto-cost reference-bandwidth 10000

For future-proofed 100 Gbps networks:

router ospf 1
 auto-cost reference-bandwidth 100000

The unit for auto-cost reference-bandwidth is Mbps. When you change the value, IOS will warn you that all OSPF costs will be recalculated and advise you to update every router in the domain. Heed that warning — a mismatch will cause routing loops or suboptimal paths.

You can also set the cost manually on a per-interface basis using ip ospf cost <value>. A manually configured cost always takes precedence over the auto-calculated value. This is useful for traffic engineering when you want to influence path selection independently of raw link speed.

The SPF Algorithm and Metric Accumulation

OSPF uses Dijkstra's Shortest Path First (SPF) algorithm to compute the least-cost path to every destination in the network. Each router maintains a link-state database (LSDB) describing the entire topology of the OSPF area, then independently runs SPF to build its routing table.

The metric that SPF minimizes is the path cost: the sum of OSPF costs on every outgoing interface along the path from source to destination. Costs on the incoming interfaces of remote routers are not counted — only the egress cost at each hop matters.

Consider a simple three-router topology: R1 — R2 — R3, where R1 also has a direct link to R3. If the R1–R2 link is GigabitEthernet (cost 1 with default ref-bw) and the R2–R3 link is FastEthernet (cost 1), the two-hop path R1 → R2 → R3 has a total cost of 2. If the direct R1–R3 link is also FastEthernet (cost 1), OSPF will prefer the direct path. But if R1–R3 is a T1 line (cost 65 with default ref-bw), OSPF correctly prefers the two-hop path through the faster links.

This is exactly the kind of intelligent path selection OSPF is designed for — but it only works correctly when your reference bandwidth is set high enough to differentiate between your actual link speeds.

IOS Commands Reference

Key commands for OSPF cost management on Cisco IOS and IOS-XE:

CommandEffect
router ospf 1Enter OSPF process configuration mode (process ID 1)
auto-cost reference-bandwidth <Mbps>Set the reference bandwidth for all interface cost calculations in this process
interface Gi0/0Enter interface configuration mode
bandwidth <Kbps>Set the logical bandwidth used by OSPF cost auto-calculation (does not affect actual link speed)
ip ospf cost <1–65535>Override the calculated cost with a static value on this interface
ip ospf priority <0–255>Influence DR/BDR election (0 = never DR); not related to cost
show ip ospf interface <name>Display OSPF parameters for an interface, including its current cost
show ip ospf databaseDisplay the LSDB — verify LSAs and their advertised costs
show ip route ospfDisplay OSPF-learned routes and their total path costs
debug ip ospf eventsReal-time OSPF event log — useful after changing reference bandwidth

Worked Examples

Example 1: Default Reference Bandwidth Masks Speed Differences

A campus network has three links: a 1 Gbps core link, a 100 Mbps distribution link, and a 10 Mbps access link. With the default 100 Mbps reference bandwidth:

1 Gbps core: cost = max(1, ⌈100M / 1G⌉) = max(1, 0.1) = 1

100 Mbps dist: cost = max(1, ⌈100M / 100M⌉) = max(1, 1) = 1

10 Mbps access: cost = max(1, ⌈100M / 10M⌉) = max(1, 10) = 10

OSPF sees the 1 Gbps and 100 Mbps links as identical. A path through two 100 Mbps hops (cost 2) will be preferred over a single 1 Gbps hop (cost 1 + 1 = 2) — they tie! Tie-breaking is implementation-dependent and may result in traffic taking the slower path.

Example 2: 10 Gbps Reference Bandwidth Correctly Ranks Links

Same network, but with auto-cost reference-bandwidth 10000 (10 Gbps):

1 Gbps core: cost = max(1, ⌈10G / 1G⌉) = max(1, 10) = 10

100 Mbps dist: cost = max(1, ⌈10G / 100M⌉) = max(1, 100) = 100

10 Mbps access: cost = max(1, ⌈10G / 10M⌉) = max(1, 1000) = 1000

Now every link has a distinct, proportional cost. The 1 Gbps core link is ten times cheaper than the 100 Mbps distribution link. OSPF will strongly prefer paths through faster links, which is exactly the desired behavior.

Example 3: Manual Cost Override for Traffic Engineering

You have two parallel 1 Gbps links between two routers. With a 10 Gbps reference bandwidth, both have cost 10. You want to use one as primary and the other as standby:

! Primary link — keep auto-calculated cost of 10
interface GigabitEthernet0/0
 ! no ip ospf cost  (let it auto-calculate)

! Standby link — raise cost to make it less preferred
interface GigabitEthernet0/1
 ip ospf cost 50

With this configuration, OSPF prefers the primary link (cost 10) over the standby (cost 50). Traffic fails over to the standby link automatically if the primary goes down, but the standby is never used while both links are up.

Frequently Asked Questions

What is the valid range for OSPF cost?

OSPF interface cost is a 16-bit unsigned integer with a valid range of 1 to 65,535. The minimum of 1 is enforced by the protocol — a cost of 0 would imply a zero-latency, infinite-bandwidth link, which cannot exist. The maximum of 65,535 limits the practical depth of OSPF topologies, though real networks rarely approach this limit.

Does changing the reference bandwidth disrupt traffic?

Yes, temporarily. Changing auto-cost reference-bandwidth triggers a recalculation of all interface costs, which causes the SPF algorithm to run on every router in the OSPF area. Routes may briefly flap as the topology database converges. Plan this change during a maintenance window, apply it to all routers consistently, and monitor convergence with debug ip ospf events and show ip ospf statistics.

Can I mix manual and auto-calculated costs in the same OSPF domain?

Yes. A manually configured ip ospf cost on an interface always overrides the auto-calculated value. This is useful for traffic engineering when you need fine-grained control over specific links. Just be aware that manually set costs do not automatically adjust if you change the reference bandwidth — you must review and update them manually to ensure they remain proportional to auto-calculated costs.

Why does the bandwidth command not affect actual link speed?

The IOS bandwidth interface command sets a logical bandwidth value that OSPF (and other routing protocols like EIGRP) uses for metric calculations. It has no effect on the physical clock rate or capacity of the link. The actual transmission speed is determined by the hardware, clocking configuration, or negotiated line rate. The bandwidth command exists precisely to let you decouple the routing metric from the physical interface speed when needed.

Do other vendors use the same default reference bandwidth?

Most OSPF implementations default to 100 Mbps for historical compatibility, since RFC 2328 does not mandate a specific value. Juniper JunOS defaults to 100 Mbps as well. Arista EOS uses 100 Gbps by default — a much more sensible choice for modern data centers. Always verify the default on your specific platform and software version, and align all routers in the OSPF domain to the same value regardless of vendor.

Related Calculators

  • Subnet Calculator — Calculate network address, broadcast address, and host ranges from CIDR notation.
  • Wildcard Mask Calculator — Convert between subnet masks and wildcard masks for ACLs and OSPF network statements.
  • VLSM Calculator — Design variable-length subnet masks to efficiently allocate IP address space across OSPF areas.

Disclaimer

This calculator is provided for educational and informational purposes only. While we strive for accuracy in implementing the OSPF cost formula as defined in RFC 2328 and Cisco IOS documentation, results should always be verified against your specific platform's implementation and software version. Network configuration changes carry operational risk — always test in a lab environment and plan a maintenance window before applying changes to production. We are not responsible for any network disruption, data loss, or damages arising from the use of this calculator or the configuration examples provided.


Also in Technical