auto-cost reference-bandwidth
Fix OSPF metric calculation for high-speed interfaces so GigabitEthernet, 10GE, and 100GE links have meaningfully different costs.
Definition: auto-cost reference-bandwidth is a Cisco IOS router config command. Changes the OSPF reference bandwidth used to calculate interface costs. Default is 100 Mbps, which assigns cost 1 to any interface 100 Mbps or faster — causing FastEthernet and GigabitEthernet to have the same cost.
Overview
The `auto-cost reference-bandwidth` command is a critical OSPF configuration tool that allows network engineers to adjust the reference bandwidth used by OSPF to calculate interface costs. By default, OSPF uses a reference bandwidth of 100 Mbps, meaning the cost of an interface is calculated as 100,000,000 / bandwidth (in bps). This default works well for legacy networks with Fast Ethernet (100 Mbps) as the fastest link, but modern networks often employ Gigabit Ethernet (1 Gbps), 10 Gigabit Ethernet (10 Gbps), or even higher-speed links.
Without adjusting the reference bandwidth, OSPF would assign the same cost (1) to all interfaces with bandwidths of 100 Mbps or higher, making OSPF unable to differentiate between a 1 Gbps link and a 10 Gbps link. This can lead to suboptimal routing, as OSPF may prefer a slower path over a faster one if the costs are equal. The command `auto-cost reference-bandwidth [mbps]` overrides the default 100 Mbps reference, allowing you to set a higher value (e.g., 10000 for 10 Gbps) so that higher-speed interfaces receive proportionally lower costs.
For example, with a reference bandwidth of 10000 Mbps (10 Gbps), a 1 Gbps interface gets a cost of 10, while a 10 Gbps interface gets a cost of 1, enabling OSPF to make better path selections. This command is typically used during initial OSPF deployment or when upgrading link speeds across the network. It is an alternative to manually setting the `ip ospf cost` command on individual interfaces, which can be tedious and error-prone in large networks.
The `auto-cost reference-bandwidth` command applies globally to all OSPF processes on the router, ensuring consistency. It is important to note that this command must be configured on all routers in the OSPF domain to maintain consistent cost calculations; otherwise, routing loops or suboptimal paths may occur. The command takes effect immediately and is stored in the running configuration.
It requires privileged EXEC mode (enable) to enter global configuration mode, and then router configuration mode for the OSPF process. There is no buffered output; the change is applied instantly. The command is available in IOS, IOS-XE, and some other platforms, but not in NX-OS (which uses a different mechanism).
Understanding this command is essential for CCNA and CCNP candidates, as OSPF cost calculation is a fundamental concept in OSPF path selection.
auto-cost reference-bandwidth <bandwidth-in-mbps>When to Use This Command
- Fix OSPF path selection on networks with mixed FastEthernet and Gigabit links
- Required when any interface exceeds 100 Mbps — default assigns cost 1 to everything 100Mbps+
- Must be configured on ALL routers consistently or OSPF path selection will be asymmetric
- Set to 10000 for networks with 10GE links; 100000 for 100GE
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| mbps | <1-4294967> | Specifies the reference bandwidth in megabits per second (Mbps). Valid values range from 1 to 4,294,967 Mbps. Common values include 1000 (for 1 Gbps), 10000 (for 10 Gbps), and 100000 (for 100 Gbps). A common mistake is setting the value too low, which can cause OSPF to assign cost 1 to many interfaces, defeating the purpose. Ensure the value is consistent across all routers in the OSPF domain. |
Command Examples
Set reference bandwidth for Gigabit networks
Router(config)# router ospf 1
Router(config-router)# auto-cost reference-bandwidth 1000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
Router(config-router)# end
! Cost calculation: cost = reference_bw / interface_bw
! GigabitEthernet: 1000/1000 = 1
! FastEthernet: 1000/100 = 10
! Serial (1.544 Mbps): 1000/1.544 = 647 (rounded up)Understanding the Output
OSPF cost = reference_bandwidth / interface_bandwidth (rounded up, minimum 1). Default reference bandwidth = 100 Mbps: FastEthernet cost = 100/100 = 1, GigabitEthernet = 100/1000 = 0.1 → rounded to 1. Both get cost 1 so OSPF cannot differentiate them.
With reference 1000: FE = 10, GE = 1. IOS warns that all routers must use the same reference bandwidth.
Configuration Scenarios
Adjust OSPF reference bandwidth for a network with mixed 1 Gbps and 10 Gbps links
A company has upgraded its core network from Fast Ethernet to a mix of 1 Gbps and 10 Gbps links. OSPF currently uses the default 100 Mbps reference, causing all Gigabit and 10 Gigabit interfaces to have cost 1, leading to equal-cost multipath (ECMP) and suboptimal routing. The goal is to set the reference bandwidth to 10000 Mbps so that 1 Gbps links get cost 10 and 10 Gbps links get cost 1, allowing OSPF to prefer the faster 10 Gbps paths.
Topology
R1(Gi0/0)---1Gbps---(Gi0/0)R2
R1(Gi0/1)---10Gbps---(Gi0/1)R2Steps
- 1.Step 1: Enter privileged EXEC mode: Router> enable
- 2.Step 2: Enter global configuration mode: Router# configure terminal
- 3.Step 3: Enter OSPF router configuration mode for process 1: Router(config)# router ospf 1
- 4.Step 4: Set the reference bandwidth to 10000 Mbps: Router(config-router)# auto-cost reference-bandwidth 10000
- 5.Step 5: Exit configuration mode: Router(config-router)# end
- 6.Step 6: Verify the change: Router# show ip ospf | include Reference
! Full IOS config block Router> enable Router# configure terminal Router(config)# router ospf 1 Router(config-router)# auto-cost reference-bandwidth 10000 Router(config-router)# end
Verify: Use 'show ip ospf' and look for the line 'Reference bandwidth unit is 10000 Mbps'. Also check interface costs with 'show ip ospf interface brief' to confirm that Gigabit interfaces show cost 10 and 10 Gigabit interfaces show cost 1.
Watch out: A common mistake is forgetting to apply the same reference bandwidth on all routers in the OSPF domain. If R1 uses 10000 Mbps and R2 uses the default 100 Mbps, OSPF cost calculations will be inconsistent, potentially causing routing loops or suboptimal path selection.
Set reference bandwidth to support 100 Gbps links in a service provider network
A service provider is deploying 100 Gbps links between core routers. The default 100 Mbps reference would assign cost 1 to all links above 100 Mbps, making OSPF unable to differentiate between 10 Gbps and 100 Gbps. To ensure OSPF prefers 100 Gbps paths, the reference bandwidth must be increased to at least 100000 Mbps (100 Gbps).
Topology
R1(Te0/0/0)---100Gbps---(Te0/0/0)R2
R1(Te0/0/1)---10Gbps---(Te0/0/1)R2Steps
- 1.Step 1: Enter privileged EXEC mode: Router> enable
- 2.Step 2: Enter global configuration mode: Router# configure terminal
- 3.Step 3: Enter OSPF router configuration mode for process 10: Router(config)# router ospf 10
- 4.Step 4: Set the reference bandwidth to 100000 Mbps: Router(config-router)# auto-cost reference-bandwidth 100000
- 5.Step 5: Exit configuration mode: Router(config-router)# end
- 6.Step 6: Verify the change: Router# show ip ospf | include Reference
! Full IOS config block Router> enable Router# configure terminal Router(config)# router ospf 10 Router(config-router)# auto-cost reference-bandwidth 100000 Router(config-router)# end
Verify: Use 'show ip ospf interface' to verify that the 100 Gbps interface has cost 1 and the 10 Gbps interface has cost 10. Also confirm with 'show ip route' that OSPF prefers the 100 Gbps path to destinations reachable via both links.
Watch out: Setting the reference bandwidth too high (e.g., 4,294,967 Mbps) can cause OSPF to assign very high costs to slower interfaces, potentially exceeding the maximum OSPF cost of 65535. For example, a 1 Mbps link would have cost 4,294,967, which is invalid. Always ensure that the calculated costs for all interfaces are within the 1-65535 range.
Troubleshooting with This Command
When troubleshooting OSPF path selection issues, the `auto-cost reference-bandwidth` command is often a suspect. A healthy network should have consistent reference bandwidth values across all routers. Use `show ip ospf` to display the reference bandwidth; look for the line 'Reference bandwidth unit is <value> Mbps'.
If you see the default 100 Mbps on some routers and a different value on others, that indicates inconsistency. Another key indicator is the OSPF interface cost. Use `show ip ospf interface brief` to list all OSPF-enabled interfaces and their costs.
If multiple interfaces with different speeds show the same cost (especially cost 1), the reference bandwidth is likely too low. For example, if both a GigabitEthernet and a 10 GigabitEthernet interface show cost 1, the reference bandwidth is probably still at 100 Mbps. To diagnose, first verify the reference bandwidth on each router.
If inconsistent, reconfigure all routers to use the same value. Next, check the actual interface bandwidth with `show interfaces` to ensure the bandwidth setting matches the physical speed. OSPF uses the configured bandwidth (set with `bandwidth` command) for cost calculation, not the actual negotiated speed.
If an interface has an incorrect bandwidth setting, OSPF cost will be wrong. For example, a 1 Gbps interface might have a bandwidth of 1000000 kbps (1 Gbps) by default, but if someone changed it to 100000 kbps (100 Mbps), OSPF would calculate cost as if it were a 100 Mbps link. To correct this, use the `bandwidth` command to set the correct speed.
Another common symptom is unexpected ECMP (equal-cost multipath) where OSPF load-balances across links of different speeds. This happens when the reference bandwidth is too low, causing multiple interfaces to have the same cost. To resolve, increase the reference bandwidth so that faster links get lower costs.
You can also manually set costs with `ip ospf cost` on specific interfaces, but this is less scalable. When troubleshooting, correlate OSPF costs with the routing table using `show ip route ospf`. If a slower path is preferred over a faster one, check the costs of both paths.
Use `show ip ospf interface` to see the cost of each interface along the path. Additionally, use `debug ip ospf spf` to see how OSPF calculates costs during SPF computation. However, use debug sparingly in production.
Finally, remember that OSPF cost is only one factor in path selection; other attributes like administrative distance and route type also matter. But if the issue is cost-related, the reference bandwidth is often the root cause.
CCNA Exam Tips
CCNA exam: the default reference bandwidth of 100 Mbps is a classic OSPF design flaw for modern networks
OSPF cost can also be set manually with ip ospf cost <value> on the interface — this overrides the auto-calculated cost
For CCNA labs: if you see GE and FE with the same OSPF cost, auto-cost reference-bandwidth is the fix
Common Mistakes
Setting auto-cost only on some routers — OSPF costs become asymmetric (different costs going vs returning)
Forgetting that minimum cost is always 1 (cannot be 0)
Not realising that ip ospf cost set directly on an interface overrides auto-cost reference-bandwidth for that interface only
auto-cost reference-bandwidth vs show ip ospf neighbor
Although both commands relate to OSPF, they serve entirely different functions—one sets a global parameter influencing route cost calculation, while the other is a diagnostic tool for verifying neighbor adjacencies. They are often referenced together when tuning OSPF performance or troubleshooting adjacency issues.
| Aspect | auto-cost reference-bandwidth | show ip ospf neighbor |
|---|---|---|
| Configuration Mode | Router configuration (config-router) | Privileged EXEC (#) |
| Persistence | Persists in running-config when non-default | Output only, no configuration impact |
| Effect on OSPF | Changes cost calculation for all interfaces; affects route selection | None; only displays current neighbor state |
| Precedence / Scope | Global per OSPF process; overridden by ip ospf cost on interface | N/A (diagnostic) |
| Typical Use | Used when network includes links faster than 100 Mbps to differentiate costs | Used to verify OSPF adjacencies and troubleshoot neighbor issues |
Use auto-cost reference-bandwidth when your network has links faster than 100 Mbps and you want OSPF to differentiate costs for FastEthernet, GigabitEthernet, etc.
Use show ip ospf neighbor when you need to verify that OSPF adjacencies have formed and check the state of neighbor relationships.
Platform Notes
In IOS-XE, the `auto-cost reference-bandwidth` command behaves identically to classic IOS. The syntax and output are the same. However, in IOS-XE, the command is also available under the OSPFv3 router configuration for IPv6.
In NX-OS (Cisco Nexus switches), OSPF does not use the `auto-cost reference-bandwidth` command. Instead, NX-OS uses a different mechanism: the OSPF cost is calculated based on the interface bandwidth, but the reference bandwidth is fixed at 100 Mbps by default. To change the reference bandwidth in NX-OS, you must use the `ip ospf cost` command on each interface or use the `auto-cost reference-bandwidth` command under the OSPF router configuration mode, but note that NX-OS syntax may require `auto-cost reference-bandwidth` in some versions, though it is not universally supported.
In Cisco ASA, OSPF is not typically used; ASAs run routing protocols like OSPF in transparent mode or as a router, but the command is not available. For IOS-XR, the equivalent command is `auto-cost reference-bandwidth` under the OSPF router configuration, but the syntax may require specifying the bandwidth in kilobits per second (kbps) rather than Mbps. For example, in IOS-XR, you might use `auto-cost reference-bandwidth 10000000` for 10 Gbps.
Always check the specific platform documentation. In older IOS versions (12.x), the command was introduced in later releases; ensure your IOS version supports it. In 15.x and 16.x, it is fully supported.
The command is not available in IOS for Catalyst switches running IOS-based software; it is only for routers and some higher-end switches. For Catalyst switches running IOS-XE, it is available. Always verify with `show ip ospf` to confirm the reference bandwidth setting.
Related Commands
clear ip ospf process
Resets all OSPF processes, tearing down all neighbour adjacencies and flushing the LSDB, forcing OSPF to re-elect the DR/BDR and rebuild the routing table from scratch.
show ip ospf neighbor
Displays OSPF neighbour table showing router IDs, adjacency state, dead timer, and the interface the neighbour is reachable through.
show ip route
Displays the IP routing table showing all known routes, their source protocols, administrative distances, metrics, next-hops, and outgoing interfaces.
Practice for the CCNA 200-301
Test your knowledge with practice questions covering all CCNA 200-301 exam domains.
Practice CCNA 200-301 Questions