• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Roger Perkin

Network Automation Architect

  • Network Automation
    • Network Automation Courses
    • What is NetDevOps?
    • Workflow Orchestration
    • Ansible Automation Platform
    • Ansible Workshop
    • What is Network Automation?
    • Network Automation Tools
    • ContainerLab
    • Ansible Training
      • What is Ansible?
      • Ansible Tutorial for Beginners
      • Ansible Network Automation
      • Ansible Inventory Example
    • Python Network Automation
      • Nornir
      • Python Network Automation Course
      • Python for Network Engineers
      • Python VENV / Virtual Environment Tutorial
      • Python Tutorial for Beginners
      • pyATS
    • Network Source of Truth
      • NetBox
      • Infrahub
    • NetDevops
    • DevOps Tutorial
      • Git Training
      • Terraform Training
      • Linux Training
      • Kubernetes Training
      • Devops Training Course
      • Azure Devops Training
    • Terraform
    • GIT
      • Git Commands
      • What is GitHub?
    • Docker Training
    • Confluence
    • Microsoft Azure
  • Cisco
    • ISE
    • SD WAN Training
    • Password Recovery
    • Software-Upgrade-Guides
    • BGP
    • Data Center
    • WIRELESS
  • CCIE
  • Blog
  • About
    • My Red Special Guitar
  • Contact

OSPF cost calculation

Home » OSPF Tutorials

How does OSPF work out the interface cost?

By default the ospf cost calculation is based on a reference bandwidth of 100Mb

The calculation is Reference BW  / Configured BW

So for a 100Mb interface using the default reference bandwidth of 100Mb

The calculation is 100Mb / 100Mb =1

However with modern networks 100Mb is not the fastest interface and 1G and 10G interfaces are common however the ospf cost can go no lower than 1 so it cannot differntiate between a 100Mb interface or a 1G / 10G interface.

To overcome this issue you can set an auto-cost reference bandwidth  to affect this calculation.

This is set in the ospf process

Router1(config)#router ospf 1
Router1(config-router)#auto-cost reference-bandwidth ?
<1-4294967>  The reference bandwidth in terms of Mbits per second
Router1(config-router)#auto-cost reference-bandwidth 20000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
Router1(config-router)#

Note the reference bandwidth command warns you that you need to make the same change across all your routers. This is to ensure all routers can make their calcuations on the same information.

So how does this affect your ospf int cost?

Router1#sh ip ospf int
FastEthernet0/0 is up, line protocol is up
Internet Address 10.251.251.162/28, Area 1
Process ID 1, Router ID 195.89.22.116, Network Type BROADCAST, Cost: 200

As you can see from the output of sh ip ospf interface, the Cost of this interface is now 200

The other way of affecting the cost of an interface is through the ip ospf cost command on the interface itself – this will override the calculated cost

Router1(config)#int f1/0
Router1(config-if)#ip ospf cost 12345

Router1#sh ip ospf int
FastEthernet1/0 is up, line protocol is up
Internet Address 123.123.123.123/28, Area 1
Process ID 1, Router ID 195.89.22.116, Network Type BROADCAST, Cost: 12345

As you can see from the output of sh ip ospf int the cost has now changed to 12345

This is great fun in the lab but you need to ensure you have your interface costs consistent across your network to ensure optimum routing path calculations.

Category: OSPF TutorialsTag: auto-cost reference bandwidth, ospf cost calculation
ansible course for network engineers
Get Access to my Ansible Course NOW
Previous Post:RIPv2 Authentication
Next Post:CCIE Data Centre or CCIE Data Center??

Sidebar

Hi I'm Roger Perkin,
Based in the UK working as a Network Automation Architect, CCIE #50038
About Roger | Twitter | Linkedin

python course for network engineers

Topics

Network Automation
Ansible
Python for Network Automation
CCIE
Cisco ISE
F5 Certification
BGP
OSPF
Network Automation Conferences
auvik promo banner
Pluralsight Trial

Git for Network Engineers

Ansible vs Nornir

Start learning today with my Network Automation Courses

Master Ansible, Python, Git, Nornir, Jenkins and more..


Buy me a coffeeBuy me a coffee

ansible network automation course

Have you seen my YouTube Channel?

YouTube Subscribe

Let’s get started

Take a look at my premium courses on Ansible, Nornir & Git or buy them all with the Network Automation Bundle!

Network Automation Courses

Navigation

Python VENV Tutorial
Python for Network Engineers

Network Automation
Network Automation Courses
Network Discovery Tools
Network Automation Conferences
Ansible Training
What is Ansible?
Devops Tutorial
Network Source of Truth
DevOps Glossary
Network Monitoring Software

Contact

Contact

Get in touch with me here

[email protected]

  • Twitter
  • LinkedIn
  • YouTube
Buy me a coffeeBuy me a coffee

Copyright © 2025 · Roger Perkin · All Rights Reserved · Privacy Policy – Terms