OSPF Interface Cost Calculator
Calculate OSPF interface cost online from reference bandwidth, interface speed, integer policy, and manual overrides for routing-change planning.{{ result.summaryTitle }}
| Cost factor | Value | Detail | Copy |
|---|---|---|---|
| {{ row.factor }} | {{ row.value }} | {{ row.detail }} |
| Check | Recommendation | Reason | Copy |
|---|---|---|---|
| {{ row.check }} | {{ row.recommendation }} | {{ row.reason }} |
| Interface speed | Auto cost | Raw ratio | Path note | Copy |
|---|---|---|---|---|
| {{ row.speedLabel }} | {{ row.costLabel }} | {{ row.rawRatioLabel }} | {{ row.note }} |
Introduction:
Open Shortest Path First (OSPF) cost is the numeric metric a router advertises for an interface, then adds across links when choosing a shortest path. Lower total cost wins. Because the value can steer traffic away from one link and toward another, a small cost mismatch can change equal-cost paths, backup behavior, and maintenance expectations.
Interface cost is often derived from bandwidth. A domain-wide reference bandwidth is divided by the interface bandwidth, then the result is reduced to an integer cost. That simple ratio is useful because faster links usually receive lower costs, but it creates a planning problem once several fast links collapse to the same minimum value of 1.
The reference must be chosen with the whole routing domain in mind. A 100 Mbps reference makes 1 Gbps, 10 Gbps, and 100 Gbps interfaces all advertise cost 1, so the protocol cannot separate those speeds by auto-cost alone. Raising the reference can restore separation, but changing it on only part of the domain can make equal links advertise different costs.
Manual interface cost is a separate policy choice. It can be useful for traffic engineering, backup links, or platform-specific exceptions, but it also means future reference-bandwidth changes will not move that interface unless the manual value is updated too.
Technical Details:
OSPF stores and floods link-state advertisements, then each router runs shortest-path calculation over the collected link costs. RFC 2328 describes path cost as the sum of the advertised costs of the path's constituent links. The interface value therefore matters both locally and to every other router that computes a route through that link.
Most router platforms expose an automatic cost model based on a reference bandwidth. The numerator is the reference value for the routing domain, commonly entered in Mbps on router commands. The denominator is the interface bandwidth value used by the routing stack, which may be an administrative bandwidth setting rather than the physical port's maximum speed.
Formula Core:
The auto-cost formula divides reference bandwidth by interface bandwidth, applies the selected integer policy, then clamps the result to the valid OSPF cost range used for the estimate.
| Symbol | Meaning | Tool field or result |
|---|---|---|
B_ref |
Reference bandwidth converted to Mbps | Reference bandwidth |
B_iface |
Interface bandwidth converted to Mbps | Interface bandwidth |
R_raw |
Fractional cost ratio before integer handling | Raw cost ratio |
C_auto |
Formula-derived interface cost after rounding and bounds | Auto interface cost |
C_effective |
Advertised interface cost after any manual override | Effective advertised cost |
The integer policy matters when the raw ratio is not a whole number. Floor / truncate matches common router examples and is the normal first choice for auto-cost estimates. Round nearest and Ceiling help compare conservative planning choices, especially when the ratio sits close to the next integer.
| Boundary | Rule used here | Why it matters |
|---|---|---|
| Reference bandwidth | At least 1 Mbps and no more than 4,294,967 Mbps |
Matches common auto-cost command limits and prevents meaningless ratios. |
| Interface bandwidth | Greater than 0 |
A zero denominator cannot produce an OSPF cost. |
| Cost ceiling | 1 to 65,535 |
The standard 16-bit OSPF cost ceiling keeps very slow links from producing impossible advertised costs. |
| Manual override | 0 means none; otherwise 1 through the selected ceiling |
A configured interface cost bypasses the auto-cost formula. |
| Minimum cost | Auto-cost is clamped to at least 1 |
Fast links with a raw ratio below one still advertise cost 1. |
The calculation is deterministic for a given input set. Changing the reference bandwidth can move every formula-based interface cost in the domain, while a manual cost changes only the selected interface and remains fixed until the configuration is changed.
Everyday Use & Decision Guide:
Start with the reference bandwidth you intend to use across the OSPF domain. For modern networks, 100 Gbps, 400 Gbps, or a value above the fastest production link often gives better separation than the old 100 Mbps default. Use the interface bandwidth that OSPF will actually read for that interface, not a marketing label or a physical capability that the router is not using for metric calculation.
Leave Configured override at 0 when you want the formula to decide the advertised cost. Enter a manual cost only when configuration already contains an interface-level override or when you are intentionally modeling one. The summary will switch from Auto-cost active to Manual override active, and Effective advertised cost will follow the manual value.
- Use
Floor / truncatefor normal router-style estimates unless your platform or design review requires a different policy. - Keep
Cost ceilingat65,535unless a lab platform documents a different accepted maximum. - Open
Cost Ledgerwhen you need the exact reference, interface, raw ratio, auto-cost, override, and effective cost in one place. - Open
Path Guidancebefore a change window. It flags reference consistency, high-speed separation, manual override policy, range guard, and change-window risk. - Use
Cost Separation LadderandSpeed Cost Tableto see whether common 10M through 400G tiers still receive distinct costs under the selected reference.
A cost of 1 does not mean a link is always preferred or congestion-free. It only means the interface has reached the minimum OSPF metric for this calculation. If several high-speed tiers all show cost 1, OSPF will need other costs, topology differences, manual policy, or equal-cost behavior to decide how traffic is shared.
The calculation uses typed values in the browser. It does not log in to routers or read live interface bandwidth, so confirm the final auto-cost reference-bandwidth setting, interface bandwidth value, and any ip ospf cost override before treating the result as deployment evidence.
Step-by-Step Guide:
Use one pass for the current configuration, then another pass for the proposed reference bandwidth if you are planning a domain-wide change.
- Enter
Reference bandwidthand choose its unit. TheCost Ledgerwill show the command-style Mbps value used as the numerator. - Enter
Interface bandwidthand choose its unit. Check the summary line for the displayed division, such asAuto-cost 10 from 100.00 Gb/s / 10.00 Gb/s. - Set
Configured overrideto0for formula-based cost, or enter a value from1to the selected ceiling when a manual interface cost should win. - Open
Advancedto changeInteger policyorCost ceiling. If the result reports a capped or minimum-cost state, compareRaw cost ratiowithAuto interface cost. - If the red
Check OSPF cost inputsmessage appears, correct the named field. Common fixes are raising reference bandwidth to at least1 Mbps, entering an interface bandwidth greater than0, or keeping manual cost inside the ceiling. - Review
Path Guidance, then compareCost Separation LadderandSpeed Cost Tablebefore copying JSON or table data for a change note.
A useful handoff includes Effective advertised cost, the selected reference bandwidth, the raw ratio, whether a manual override is active, and any guidance row that asks for a reference or range check.
Interpreting Results:
Effective advertised cost is the value to read first because it includes the manual override rule. If no override is active, it matches Auto interface cost. If a manual value is entered, the manual value wins and the ledger shows the delta versus auto-cost.
Raw cost ratio explains why the final integer changed. A raw value below 1 is forced up to cost 1. A raw value above the selected ceiling is capped. A fractional raw value can differ under Floor / truncate, Round nearest, and Ceiling.
Minimum cost floormeans the selected interface is faster than the reference can distinguish.Cost cappedmeans the formula produced an integer above the selected ceiling.Manual override activemeans reference-bandwidth changes will not affect this interface until the override is removed or edited.Path Guidanceshould slow a change when high-speed tiers collapse to cost1or when the reference value differs from the domain standard.
Worked Examples:
Modern reference for a 10G uplink:
With Reference bandwidth set to 100 Gbps, Interface bandwidth set to 10 Gbps, Configured override left at 0, and Floor / truncate selected, Raw cost ratio is 10.00. The Auto interface cost and Effective advertised cost both show 10, and the summary reports Auto-cost active.
Default-style reference that collapses fast links:
A 100 Mbps reference with a 1 Gbps interface produces a raw ratio of 0.100. The final Auto interface cost becomes 1 because OSPF cost cannot go below one. In Speed Cost Table, 1G, 10G, 25G, 40G, 100G, and 400G tiers can all share cost 1, so the guidance recommends raising the reference if those tiers must differ.
Manual traffic-engineering cost:
Keep the 100 Gbps reference and 10 Gbps interface, then enter 250 in Configured override. The formula still shows auto-cost 10, but Effective advertised cost becomes 250. The ledger reports a positive manual delta, which is a cue to document why the interface should remain outside the reference-bandwidth formula.
Out-of-range planning input:
If Reference bandwidth is entered below 1 Mbps, or if Configured override is higher than Cost ceiling, the summary changes to Review inputs and the red validation message names the bad field. Correct the input before using the JSON or table output, because the result has switched from a deployable estimate to an input audit.
FAQ:
What reference bandwidth should I use?
Use the same value across the OSPF domain and choose a value high enough to separate the fastest links you care about. The tool accepts Kbps, Mbps, Gbps, and Tbps inputs, then shows the command-style Mbps value in Cost Ledger.
Why do several different speeds all show cost 1?
The raw ratio fell below one for those speeds, so the calculator applied the minimum OSPF cost of 1. Raise the reference bandwidth if those speeds need distinct auto-cost values.
Does a configured interface cost override auto-cost?
Yes. Entering a manual value from 1 through the selected ceiling makes Effective advertised cost follow that override. Enter 0 when no manual cost is configured.
Why does changing the integer policy change the result?
The raw ratio can be fractional. Floor / truncate drops the fraction, Round nearest rounds to the nearest integer, and Ceiling moves up to the next integer before the minimum and maximum bounds are applied.
Does this read live OSPF settings from a router?
No. The calculation uses the values typed into the page. It does not query router configuration, interface bandwidth, neighbors, route tables, or link-state advertisements.
Glossary:
- OSPF
- Open Shortest Path First, a link-state routing protocol that chooses paths by accumulated cost.
- Reference bandwidth
- The domain-wide numerator used by auto-cost calculations.
- Interface bandwidth
- The bandwidth value OSPF uses as the denominator for an interface's auto-cost.
- Auto-cost
- The formula-derived interface cost before any manual override is applied.
- Manual override
- An interface-level cost that bypasses the reference-bandwidth formula.
- Cost ceiling
- The maximum cost allowed in the estimate, normally
65,535. - LSA
- A link-state advertisement that carries topology and cost information through the OSPF area.
References:
- RFC 2328: OSPF Version 2, IETF, April 1998.
- Review OSPF Frequently Asked Questions, Cisco.
- OSPFv2 documentation, FRRouting.
- Cisco NX-OS auto-cost command reference, Cisco.