OSPF Cost Calculator

Calculate OSPF (Open Shortest Path First) interface costs based on reference bandwidth and interface speed. OSPF uses cost to determine the best path to a destination — lower cost means a preferred route. This calculator helps you plan and verify OSPF routing decisions across your network.

Cisco default: 100 Mbps. Recommended: 10,000+ Mbps for modern networks.

OSPF Cost Calculator
Figure 1 — OSPF Cost Calculator

What Is OSPF Cost?

OSPF cost is the metric OSPF uses to determine the best path to a destination network. It's calculated by dividing a reference bandwidth by the interface bandwidth. Lower cost indicates a faster, preferred path. When multiple routes exist to the same destination, OSPF chooses the one with the lowest total cost.

OSPF is one of the most widely deployed interior gateway protocols. Understanding cost calculation is essential for network design, troubleshooting routing issues, and ensuring traffic takes optimal paths. For subnet planning in OSPF networks, use our Subnet Calculator.

The OSPF Cost Formula

OSPF Cost = Reference Bandwidth / Interface Bandwidth

# Cisco Default (Reference = 100 Mbps)
GigE cost = 100 / 1000 = 0.1 → rounded to 1
FastE cost = 100 / 100  = 1
Ethernet   = 100 / 10   = 10
T1 cost    = 100 / 1.544 = 64

# With Reference = 10,000 Mbps (recommended)
GigE cost  = 10000 / 1000  = 10
FastE cost = 10000 / 100   = 100
10GE cost  = 10000 / 10000 = 1

Why Reference Bandwidth Matters

The default reference bandwidth on Cisco routers is 100 Mbps. This means all interfaces faster than 100 Mbps (GigE, 10GE, 40GE) calculate a cost of 1 — making them all appear equal to OSPF. This is a critical problem in modern networks:

InterfaceSpeedCost (Ref: 100)Cost (Ref: 10,000)Cost (Ref: 100,000)
Serial / T11.544 Mbps646,47664,766
Ethernet10 Mbps101,00010,000
Fast Ethernet100 Mbps11001,000
Gigabit Ethernet1,000 Mbps110100
10G Ethernet10,000 Mbps1110
40G Ethernet40,000 Mbps112
100G Ethernet100,000 Mbps111

Pro Tip: Always set your reference bandwidth to match or exceed your fastest link speed. Use auto-cost reference-bandwidth 10000 (or higher) on ALL OSPF routers in your network. This must be consistent across every router in the OSPF domain, or routing will be suboptimal. Mismatched reference bandwidth is one of the most common OSPF configuration mistakes.

Note: OSPF cost is an integer — fractional values are rounded down to the nearest whole number, with a minimum cost of 1. This means with the default reference bandwidth of 100 Mbps, Gigabit, 10GE, and even 100GE links all have a cost of 1, making OSPF unable to prefer faster paths. Always increase the reference bandwidth to differentiate between high-speed links.

Configuring OSPF Cost

# Cisco IOS — Set reference bandwidth (all routers!)
router ospf 1
 auto-cost reference-bandwidth 10000

# Manually set interface cost (overrides auto calculation)
interface GigabitEthernet0/0
 ip ospf cost 10

# Verify OSPF cost
show ip ospf interface brief
show ip route ospf

After changing OSPF costs, verify routes are using the expected paths. Use our Network Latency Test to confirm the preferred path provides lower latency.

OSPF Path Selection

OSPF selects routes by accumulating costs along each possible path. The path with the lowest total cost wins:

PathHopsPer-Hop CostTotal CostSelected?
A → B → D (10GE + 10GE)21 + 12Yes (lowest)
A → C → D (GigE + GigE)210 + 1020No
A → B → C → D (10GE + FastE + GigE)31 + 100 + 10111No

For bandwidth-related planning alongside OSPF, use our Bandwidth Calculator.

OSPF Areas and Cost Interaction

  • Intra-area routes — Cost is the sum of all interface costs along the path within an area.
  • Inter-area routes — Cost includes the intra-area cost to the ABR plus the ABR's advertised metric.
  • External routes — Type 1 externals add internal cost; Type 2 externals use only the external metric.
  • Equal-cost multipath (ECMP) — When two paths have identical cost, OSPF load-balances across both.

Understanding these interactions is essential for networks with multiple OSPF areas. For monitoring performance across different paths, use our Ping Test and Speed Test.

Key Takeaways
  • OSPF cost = Reference Bandwidth / Interface Bandwidth (minimum 1).
  • The Cisco default reference of 100 Mbps makes all GigE+ links equal cost — always increase it.
  • Set the same reference bandwidth on ALL OSPF routers in the domain.
  • Lower cost = preferred path. OSPF sums costs along each possible route.
  • Use manual cost overrides for traffic engineering when auto-cost isn't sufficient.
  • Verify routing decisions with show ip route ospf after changes.

Video: OSPF Explained

Related Tools & Guides

Frequently Asked Questions

What is the default OSPF cost for Gigabit Ethernet?

With Cisco's default reference bandwidth of 100 Mbps, a Gigabit Ethernet interface has a cost of 1 (100/1000, rounded up to minimum 1). With a recommended reference of 10,000 Mbps, the cost becomes 10, which properly differentiates it from faster links.

Why should I change the reference bandwidth?

The default 100 Mbps reference makes all interfaces above 100 Mbps have the same cost of 1. OSPF can't distinguish between GigE, 10GE, and 100GE links, leading to suboptimal routing. Increasing the reference gives each link type a unique cost.

Does reference bandwidth need to match on all routers?

Yes, it must be identical on all routers in the OSPF domain. Mismatched reference bandwidths cause inconsistent cost calculations, leading to routing loops or suboptimal paths. Configure it in the router ospf configuration on every router.

Can I manually set OSPF cost?

Yes, using ip ospf cost <value> on an interface. Manual cost overrides the auto-calculated value and is useful for traffic engineering — for example, preferring one ISP link over another regardless of bandwidth.

What is OSPF equal-cost multipath (ECMP)?

When two or more paths to a destination have identical total cost, OSPF installs all of them in the routing table and load-balances traffic across them. By default, Cisco supports up to 4 equal-cost paths (configurable up to 16 with maximum-paths).

How does OSPF compare to BGP?

OSPF is an interior gateway protocol (IGP) for routing within an autonomous system, using link-state and cost metrics. BGP is an exterior gateway protocol (EGP) for routing between autonomous systems, using path attributes and policies. Most networks use OSPF internally and BGP externally. See our BGP ASN Lookup for more on BGP.

About Tommy N.

Tommy is the founder of RouterHax and a network engineer with 10+ years of experience in home and enterprise networking. He specializes in router configuration, WiFi optimization, and network security. When not writing guides, he's testing the latest mesh WiFi systems and helping readers troubleshoot their home networks.

Promotion for FREE Gifts. Moreover, Free Items here. Disable Ad Blocker to get them all.

Once done, hit any button as below