CCNA 200-301

CCNP Enterprise

CCNP Security

CCIE Enterprise Lab

CCIE Security Lab

CCNP Service Provider

CCNP Data Center

CCNP Collaboration

CCIE DC Lab

Open Shortest Path First (OSPF) determines the best path through a network by evaluating a single metric: cost. On a Cisco router, every OSPF-enabled interface is assigned an individual link cost based on its bandwidth, and the router sums these outgoing link costs along a path to compute the cumulative metric installed in the IP routing table.

When validating network designs, preparing for CCNA or CCNP certification exams, or diagnosing why traffic is taking a slower backup circuit, knowing where to inspect both individual interface costs and end-to-end route metrics is essential. Below, you will find how Cisco calculates default OSPF metrics, the exact CLI commands to check them, platform syntax differences across IOS and NX-OS, step-by-step configuration methods to adjust path selection, and solutions to common metric anomalies.

How Cisco Calculates Default OSPF Cost and Reference Bandwidth

Before running verification commands on the CLI, it helps to understand why certain interfaces display identical costs despite having vastly different physical speeds. By default, Cisco IOS and IOS-XE calculate an interface’s OSPF cost as being inversely proportional to its nominal bandwidth:

$$\text{OSPF Cost} = \frac{\text{Reference Bandwidth}}{\text{Interface Bandwidth}}$$

In Cisco IOS and IOS-XE, the default reference bandwidth is 100 Mbps ($10^8\text{ bps}$ or $100,000\text{ kbps}$). Because the OSPF metric field in RFC 2328 is an unsigned 16-bit integer ranging from 1 to 65535, Cisco routers use integer division (truncating decimals rather than rounding up) and enforce a minimum cost floor of 1. Consequently, any interface operating at 100 Mbps or faster calculates to a value of 1 or less and is assigned a default cost of 1.

The following comparison table breaks down how Cisco IOS calculates the default OSPF cost across standard physical and logical interface types:

Interface TypeDefault Cisco BandwidthCalculation ($100,000\text{ kbps} / \text{BW}$)Default OSPF CostPath Selection Impact
Loopback (Lo0)8,000,000 kbps (8 Gbps)Hardcoded per RFC 2328 stub host rule1Always advertised with a fixed cost of 1 unless manually overridden.
GRE Tunnel (Tu0)100 kbps$100,000 / 100$1000Treated as a very slow backup path by default.
Serial (56k)56 kbps$100,000 / 56 = 1785.71$1785Fractional remainder is truncated via integer division.
Serial (T1) (Se0/0/0)1,544 kbps (1.544 Mbps)$100,000 / 1,544 = 64.76$64Standard legacy WAN cost; fractional value .76 is dropped.
Serial (E1) (Se0/0/1)2,048 kbps (2.048 Mbps)$100,000 / 2,048 = 48.82$48Slightly preferred over T1 links due to higher nominal bandwidth.
Ethernet (Et0/0)10,000 kbps (10 Mbps)$100,000 / 10,000$10Properly penalized compared to 100 Mbps FastEthernet.
FastEthernet (Fa0/0)100,000 kbps (100 Mbps)$100,000 / 100,000$1Matches the default 100 Mbps reference bandwidth ceiling.
GigabitEthernet (Gi0/0)1,000,000 kbps (1 Gbps)$100,000 / 1,000,000 = 0.1$1Sub-1 result rounds up to minimum allowed integer of 1; tied with FastEthernet.
TenGigabitEthernet (Te0/0)10,000,000 kbps (10 Gbps)$100,000 / 10,000,000 = 0.01$1Indistinguishable from 100M and 1G links without reference bandwidth tuning.
40G / 100G Ethernet40,000,000+ kbps$< 0.0025$1Requires global reference bandwidth scaling to prevent suboptimal ECMP routing.

Key Takeaway: Without modifying the default 100 Mbps reference bandwidth, a Cisco router cannot differentiate between FastEthernet (100 Mbps), GigabitEthernet (1 Gbps), and 10-GigabitEthernet (10 Gbps) interfaces—assigning all of them a default cost of 1.

Cisco CLI Commands to Check OSPF Interface and Route Cost

With the default calculation behavior in mind, you can inspect both individual interface link costs and cumulative route metrics directly from privileged EXEC mode. Use the following Cisco IOS CLI templates and sample outputs to locate the exact cost values.

! =====================================================================
! 1. CHECK ALL OSPF INTERFACE COSTS AT A GLANCE
! Locate the "Cost" column for the per-link egress OSPF metric.
! =====================================================================
Router# show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Gi0/0        1     0               10.1.12.1/30       1     DR    1/1
Gi0/1        1     0               10.1.13.1/30       10    BDR   1/1
Se0/0/0      1     0               172.16.1.1/30      64    P2P   1/1
Lo0          1     0               192.168.1.1/32     1     LOOP  0/0

! =====================================================================
! 2. CHECK DETAILED OSPF COST ON A SPECIFIC INTERFACE
! Locate "Cost:" at the end of line 2 in the output.
! =====================================================================
Router# show ip ospf interface GigabitEthernet0/1
GigabitEthernet0/1 is up, line protocol is up 
  Internet Address 10.1.13.1/30, Area 0, Attached via Network Statement
  Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 10
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           10        no          no            Base
  Transmit Delay is 1 sec, State BDR, Priority 1

! =====================================================================
! 3. CHECK CUMULATIVE OSPF ROUTE COST IN THE IP ROUTING TABLE
! Inside [110/20]: 110 = Administrative Distance, 20 = Total OSPF Cost.
! =====================================================================
Router# show ip route ospf
      10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
O        10.2.2.0/24 [110/2] via 10.1.12.2, 01:14:22, GigabitEthernet0/0
O IA     10.3.3.0/24 [110/20] via 10.1.13.2, 00:45:10, GigabitEthernet0/1
O E2     172.30.0.0/16 [110/20] via 10.1.12.2, 00:12:04, GigabitEthernet0/0

! =====================================================================
! 4. CHECK DETAILED PATH METRIC FOR A SINGLE DESTINATION PREFIX
! Locate "metric <value>" on line 2 and "Route metric is <value>".
! =====================================================================
Router# show ip route 10.3.3.0
Routing entry for 10.3.3.0/24
  Known via "ospf 1", distance 110, metric 20, type inter area
  Last update from 10.1.13.2 on GigabitEthernet0/1, 00:45:15 ago
  Routing Descriptor Blocks:
  * 10.1.13.2, from 192.168.3.3, 00:45:15 ago, via GigabitEthernet0/1
      Route metric is 20, traffic share count is 1

Key Takeaway: Use show ip ospf interface brief to verify the local outgoing cost of each individual interface, and use show ip route ospf (reading the second number inside the [AD/Metric] brackets) to verify the cumulative end-to-end cost to reach a remote subnet.

Cisco OSPF Command Reference: IOS, IOS-XE, and NX-OS Syntax

While the core verification workflow remains consistent across Cisco routing platforms, syntax options, VRF arguments, and default reference bandwidth parameters differ between Cisco IOS / IOS-XE (Catalyst, ISR, ASR) and Cisco NX-OS (Nexus switches). The following specification details the official command syntax, output field definitions, and platform defaults.

Command Syntax Specification

  • Cisco IOS / IOS-XE Verification Syntax:
    show ip ospf [process-id] interface [brief] [interface-type interface-number]
    show ip route [vrf vrf-name] ospf [process-id]
  • Cisco NX-OS Verification Syntax:
    show ip ospf [instance-tag] interface [brief] [interface-type slot/port] [vrf vrf-name]
    show ip route [route-prefix] ospf [instance-tag] [vrf vrf-name]
  • Cisco IOS / IOS-XE Cost Configuration Syntax:
    Interface Mode: ip ospf cost <1-65535>
    Router Mode: auto-cost reference-bandwidth <1-4294967> (value specified solely as an integer in Mbps)
  • Cisco NX-OS Cost Configuration Syntax:
    Interface Mode: ip ospf cost <1-65535>
    Router Mode: auto-cost reference-bandwidth <number> [Mbps | Gbps] (defaults to Mbps if unit keyword is omitted)

Output Field Definitions

  • PID / Process ID: The locally significant OSPF process identifier (IOS/IOS-XE) or instance tag (NX-OS) to which the interface belongs.
  • Cost: The unsigned 16-bit integer (1 to 65535) representing the link-state metric advertised in Router LSAs (Type 1) for this interface.
  • Topology-MTID Cost: Displays Multi-Topology Routing (MTR) specific costs in IOS-XE; MTID 0 (Base) represents the standard IPv4 unicast OSPF topology cost.
  • Distance: The Administrative Distance of the routing protocol (110 by default for OSPF in both IOS-XE and NX-OS).
  • Metric: The cumulative sum of outgoing interface costs from the local router to the target network (plus external redistribution costs for E1/E2 or N1/N2 routes).

Platform Default Differences (IOS/IOS-XE vs. NX-OS)

ParameterCisco IOS / IOS-XE DefaultCisco Nexus NX-OS Default
Default Reference Bandwidth100 Mbps40 Gbps (40,000 Mbps)
Default 1G Interface Cost140
Default 10G Interface Cost14
Default 40G Interface Cost11
Loopback Interface Cost11

Reference Documentation: Cisco IOS IP Routing: OSPF Command Reference and Cisco Nexus 9000 Series NX-OS Unicast Routing Configuration Guide.

Key Takeaway: In mixed data center environments where Cisco IOS-XE routers peer with Cisco Nexus NX-OS switches, you must explicitly align the auto-cost reference-bandwidth on both platforms because NX-OS defaults to 40 Gbps while IOS-XE defaults to 100 Mbps.

How to Change OSPF Cost on a Cisco Router

Once you have checked your current OSPF metrics and identified links that need adjustment, Cisco IOS provides three methods to modify OSPF cost. You can scale costs globally across all interfaces, override the cost on a single interface, or adjust the nominal interface bandwidth.

Step 1: Scale Costs Globally Using auto-cost reference-bandwidth (Recommended Baseline)

To allow OSPF to automatically distinguish between FastEthernet, 1G, 10G, 40G, and 100G interfaces using the calculation formula covered earlier, increase the global reference bandwidth under the OSPF routing process. Set this value at least as high as the fastest link in your network (in Mbps), and configure the exact same value on every router in the OSPF domain.

Router# configure terminal
Router(config)# router ospf 1
! Set reference bandwidth to 100,000 Mbps (100 Gbps)
Router(config-router)# auto-cost reference-bandwidth 100000
% OSPF: Reference bandwidth is changed. 
        Please ensure reference bandwidth is consistent across all routers.
Router(config-router)# end

With a 100000 Mbps (100 Gbps) reference bandwidth applied, Cisco IOS automatically recalculates default interface costs as follows:
* 100 Gbps interface: Cost = 1
* 40 Gbps interface: Cost = 2
* 10 Gbps interface: Cost = 10
* 1 Gbps interface: Cost = 100
* 100 Mbps interface: Cost = 1000

Step 2: Override Cost on a Specific Interface Using ip ospf cost (For Traffic Engineering)

When you need to steer traffic away from a specific link (such as a high-latency satellite circuit or a backup WAN connection) without changing the global formula, manually assign a cost between 1 and 65535 directly on the interface. An explicit ip ospf cost command always takes precedence over both auto-cost reference-bandwidth and the interface bandwidth setting.

Router# configure terminal
Router(config)# interface GigabitEthernet0/1
! Manually set the OSPF link cost to 500
Router(config-if)# ip ospf cost 500
Router(config-if)# end

Step 3: Adjust Nominal Interface Bandwidth Using bandwidth (Use with Caution)

If a physical GigabitEthernet port is connected to an ISP circuit throttled to a lower sub-rate speed (for example, a 50 Mbps Metro Ethernet handoff), you can configure the informational bandwidth command in kilobits per second (kbps). OSPF will dynamically recalculate the link cost based on this new bandwidth value—provided ip ospf cost is not configured on the interface.

Router# configure terminal
Router(config)# interface GigabitEthernet0/2
! Specify 50 Mbps in kilobits per second (50,000 kbps)
Router(config-if)# bandwidth 50000
Router(config-if)# end

Note: Avoid using the bandwidth command solely to manipulate OSPF routing if other features rely on the interface speed. Changing the interface bandwidth parameter also alters EIGRP composite metric calculations, QoS policy bandwidth percentages, and SNMP ifSpeed reporting. Prefer ip ospf cost whenever your goal is strictly OSPF path manipulation.

Key Takeaway: Use auto-cost reference-bandwidth across all routers to establish an accurate baseline for high-speed interfaces, and use per-interface ip ospf cost whenever you need surgical traffic engineering overrides.

Cisco OSPF Cost and Verification CLI Cheat Sheet

Bookmark or copy this consolidated list of Cisco CLI commands for daily network administration, change validation, and CCNA/CCNP lab troubleshooting:

  1. show ip ospf interface brief — Displays a compact table of every OSPF-enabled interface, its area assignment, IP address, and current link Cost.
  2. show ip ospf interface <interface> | include Cost — Filters detailed interface output to immediately return the process ID, network type, and exact link cost on a single line.
  3. show ip route ospf — Lists all OSPF-learned prefixes in the global routing table along with their [Administrative Distance / Cumulative Cost] values.
  4. show ip ospf border-routers — Displays the internal OSPF path cost required to reach Area Border Routers (ABRs) and Autonomous System Boundary Routers (ASBRs)—critical for diagnosing tie-breakers on External Type 2 (O E2) routes.
  5. show ip ospf database router self-originate — Inspects the local router’s Type 1 Router LSA to verify the exact TOS 0 Metrics (link costs) being advertised to OSPF neighbors.
  6. show running-config | section router ospf — Checks the active OSPF process configuration to verify whether a custom auto-cost reference-bandwidth has been applied.
  7. show interfaces <interface> | include BW — Displays the nominal hardware or configured bandwidth (BW in Kbit/sec) that OSPF uses as the denominator in its cost formula.
  8. ip ospf cost <1-65535> — Interface configuration command that hardcodes the outgoing OSPF link metric, bypassing bandwidth-based calculations.
  9. auto-cost reference-bandwidth <mbps> — Router OSPF configuration command that changes the numerator in the default cost formula from 100 Mbps to a user-defined value.

Key Takeaway: Combining show ip ospf interface brief with show ip ospf database router self-originate and show ip route ospf lets you trace OSPF metrics across all three stages: local interface calculation, LSA advertisement, and final RIB installation.

Troubleshooting Unexpected OSPF Path Costs and Suboptimal Routing

Even when interfaces are up and neighbors reach the FULL state, OSPF can occasionally select a slower path or display an unexpected metric in the routing table. The following FAQ addresses the most common real-world edge cases.

Why is OSPF routing traffic over a 100 Mbps link instead of a 10 Gbps link?

If the router is still using the default 100 Mbps reference bandwidth, both the 100 Mbps link and the 10 Gbps link calculate to a cost of 1. Because OSPF sees identical link costs, it treats a single-hop 100 Mbps path as equal to a single-hop 10 Gbps path (performing equal-cost multi-path load balancing across both) or even prefers a single-hop 100 Mbps link (total cost 1) over a two-hop 10 Gbps path (total cost 2). Configure auto-cost reference-bandwidth across all routers to resolve this.

Do mismatched reference bandwidths break OSPF neighbor adjacencies?

No. Reference bandwidth is a locally significant calculation parameter and is not exchanged inside OSPF Hello packets, so neighbors will still form FULL adjacencies. However, mismatched reference bandwidths cause routers in the same area to advertise vastly different cost scales in their LSAs, leading to asymmetric routing, suboptimal path selection, and unexpected ECMP behavior.

How is OSPF cost calculated on an EtherChannel (Port-Channel) or subinterface?

On a logical Port-channel interface, Cisco IOS dynamically calculates the interface bandwidth as the sum of all active physical member links. For example, four bundled 1 Gbps interfaces yield an aggregate Port-Channel bandwidth of 4,000,000 kbps (4 Gbps). If the reference bandwidth is set high enough (such as 10000 Mbps or 40000 Mbps) and no manual ip ospf cost is configured on the Port-Channel, OSPF automatically assigns a lower cost to the bundle and dynamically increases the cost if a member link fails. On 802.1Q subinterfaces (such as GigabitEthernet0/0.10), each subinterface inherits the full nominal bandwidth of the parent physical interface unless manually modified.

Why didn’t changing ip ospf cost on my interface change incoming traffic from my neighbor?

OSPF calculates the shortest path tree by summing outgoing (egress) interface costs along the route from the calculating router to the destination. Increasing ip ospf cost on Router A’s interface only increases the metric for traffic leaving Router A via that link. Router B computes its path toward Router A using Router B’s own outgoing interface cost. To influence how upstream neighbors route traffic back to your router, you must adjust ip ospf cost on the neighbor’s egress interface.

Why does an OSPF route metric stay stuck at 20 even after I change interface costs?

Examine the route code in show ip route ospf. If the route is marked O E2 (OSPF External Type 2) or O N2 (NSSA External Type 2), it only displays the external redistribution seed metric (which defaults to 20) in the routing table and ignores internal OSPF link costs in that displayed number. Internally, the router still checks the cumulative internal cost to reach the ASBR (visible via show ip ospf border-routers) to break ties between multiple paths. If you want the routing table metric to reflect the sum of the external cost plus all internal link costs, change the redistribution command on the ASBR to use metric-type 1 (O E1).

Key Takeaway: When troubleshooting unexpected OSPF metrics, always verify whether the route is an External Type 2 (O E2) prefix, confirm that auto-cost reference-bandwidth matches across every router, and remember that OSPF only evaluates outgoing interface costs along a path.


Accurately checking and managing OSPF cost on a Cisco router comes down to distinguishing between per-link egress costs (show ip ospf interface brief) and cumulative path metrics (show ip route ospf). By auditing your interface metrics, aligning your reference bandwidth across IOS-XE and NX-OS platforms, and applying targeted ip ospf cost overrides where needed, you ensure OSPF consistently forwards traffic over your highest-capacity network paths.

Please follow and like us:
Last modified: November 17, 2026

Author

Comments

Write a Reply or Comment

Your email address will not be published.