Why can a slower path look just as good?
OSPF cost is a number a router uses to compare paths. It is a routing metric, meaning a measure used to choose a route. A smaller total cost wins when we compare eligible OSPF routes of the same type to the same destination network. Cost is not a measured download time, and OSPF does not test the current load before forwarding each packet.
The network from the first module has two paths from LAN A to LAN B. The top one, through R2, is gigabit all the way. The bottom one, through R3, includes an older 100 Mbps link between R1 and R3. With OSPF running on default settings, users complain that copies to the servers are sometimes fast and sometimes slow. R1 has two equal-cost next hops to LAN B. Some transfers use the slow link because the metric cannot distinguish it.
Here LAN means local area network. A PC in LAN A sends a file to a server in LAN B, network 192.168.4.0/24. R1 is the first router, R4 connects to the destination LAN, and R2 and R3 provide alternative routes between them. A next hop is the next router that receives the packet. These addresses identify devices and networks; they are not web addresses.
The cost formula and its 100 Mbps reference
Without an explicit cost override, Cisco IOS/IOS XE calculates an interface cost from the following division. OSPF itself advertises cost values; this bandwidth formula is the Cisco calculation used in our examples. Use the same units for both values:
cost = reference bandwidth ÷ interface bandwidth
The calculated cost is an integer: the fractional part is discarded, with a minimum cost of 1. For example, 100 ÷ 1.544 is about 64.77, giving cost 64; 100 ÷ 1000 is 0.1, giving the minimum of 1. The usual Cisco IOS/IOS XE reference bandwidth is 100 Mbps unless configured otherwise. This older default cannot distinguish many modern link speeds:
| Interface | Bandwidth | Cost with the default 100 Mbps reference | Cost with a 1 000 Mbps reference |
|---|---|---|---|
| Serial (T1) | 1.544 Mbps | 64 | 647 |
| Ethernet | 10 Mbps | 10 | 100 |
| FastEthernet | 100 Mbps | 1 | 10 |
| GigabitEthernet | 1 Gbps | 1 | 1 |
| TenGigabitEthernet | 10 Gbps | 1 | 1 |
The formula uses the interface's bandwidth value, not a live measurement of traffic or spare capacity.Read BW in show interfaces. It may come from a platform default or a configured bandwidth value, so it need not match the physical port speed or a provider's service rate. Convert units before dividing: 100000 Kbit/sec = 100 Mbps and 1000 Mbps = 1 Gbps. Confirm the resulting cost with show ip ospf interface on your software release.
With the default, FastEthernet, gigabit and 10-gigabit all cost 1. That is exactly the problem in the situation above. Raising the reference to 1 000 Mbps separates 100 Mbps from 1 Gbps; a network with 10-gigabit links can use 10 000 Mbps or more to distinguish those speeds.
Adding up a path, one outgoing interface at a time
A router adds the cost of each outgoing interface on the way to the destination, including the interface on the last router that connects to the destination LAN. Costs of incoming interfaces are not counted.
Think of each cost as an arrow leaving a router. R1→R3 uses R1's Gi0/2 cost; R3→R1 uses R3's Gi0/0 cost. Do not add both ends of one link for a packet travelling in one direction. We are calculating R1's route to LAN B, so the incoming LAN A connection adds nothing to that route. R4's outgoing connection to LAN B does count, even when that interface is passive and sends no OSPF Hellos.
Device key: LAN A, LAN B (network / site) · R1, R2, R3, R4 (router)
Lines show the example’s network connections. Read the numbered steps for traffic direction and changes.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- LAN A: Subnet 192.168.1.0/24
- R1: RID 1.1.1.1
- R2: RID 2.2.2.2
- R3: RID 3.3.3.3
- R4: RID 4.4.4.4
- LAN B: Subnet 192.168.4.0/24
- 1. Top path: cost 3. R1 Gi0/1 (1) + R2 Gi0/1 (1) + R4 Gi0/0 to LAN B (1).
- 2. Bottom path: cost 12. R1 Gi0/2, the 100 Mbps link (10) + R3 Gi0/1 (1) + R4 Gi0/0 (1).
- 3. OSPF installs the top path. R1's routing table shows O 192.168.4.0/24 [110/3] via 10.0.12.2. The bottom path stays in the LSDB as a backup if the top one fails.
Follow the top path: R1 leaves through Gi0/1 at cost 1, R2 leaves through Gi0/1 at cost 1, then R4 leaves through Gi0/0 to LAN B at cost 1. The total is 3, not 2. On the bottom path, only R1's first outgoing cost changes to 10, making the total 12. The calculation is a routing preference; it does not promise a particular file-transfer speed.
How does R1 learn the costs on R2, R3 and R4?
Each router describes its area links and their costs in a Type 1 router link-state advertisement, or router-LSA. The routers share these descriptions within the area and store them in theirlink-state database (LSDB). R1 runs the shortest path first (SPF) calculation over that information. Here, shortest means lowest total cost, rather than fewest routers or shortest cable.
show ip ospf database router 1.1.1.1Run at a privileged router prompt, such as R1#. Inspect R1's router-LSA in area 0; the link entries show advertised Metrics. These are individual link costs, not the total cost to LAN B. Use show ip route for the selected end-to-end route.
With the default reference, the 100 Mbps link would cost 1 too: both paths would total 3, and R1 would use both. That is equal-cost multi-path (ECMP). The number of installed paths depends on the platform and maximum-paths setting. Equal metrics do not necessarily mean equal physical capacity.
On Cisco platforms using Cisco Express Forwarding (CEF), the forwarding system normally groups packets into flows using a calculation called a hash. Packets in a flow commonly keep the same path. This reduces out-of-order delivery, but two equal-cost paths need not carry the same number of bytes. More paths do not make one transfer automatically use their combined capacity.
Three ways to change cost on Cisco IOS
There are three ways to influence cost. An explicit interface cost overrides the other two, which both feed the formula. The following are configuration alternatives, not three values to add. Start each block at R1(config)#, reached with configure terminal from privileged EXEC mode.
1. Set the cost directly
interface GigabitEthernet0/2
ip ospf cost 10On R1. Overrides every calculation for this interface (1 to 65 535). It affects only traffic leaving R1 through Gi0/2; R3 keeps its own cost for the opposite direction.
A high cost makes a path less preferred when a lower-cost eligible path exists. It does not disable the interface: OSPF can still use that path if it is the only available route. To investigate packet loss, check interface errors and the actual forwarding path as well as its metric.
2. Change the bandwidth the formula uses
interface GigabitEthernet0/2
no ip ospf cost
bandwidth 100000R1 global configuration mode → Gi0/2 interface mode. Remove the previous explicit override before testing the formula. bandwidth uses kbps: 100 000 kbps = 100 Mbps. This changes the calculation input, not physical speed or a traffic rate limit. Other features may read the value too.
If you only want to change OSPF's preference for one interface, setting ip ospf cost directly avoids changing a bandwidth value that other features may use. A reference-bandwidth change is useful when the whole design needs to distinguish faster links; it does not override an existing explicit interface cost.
3. Raise the reference bandwidth (recommended)
router ospf 1
auto-cost reference-bandwidth 1000In Mbps, on every router. IOS answers with a reminder: % OSPF: Reference bandwidth is changed. Please ensure reference bandwidth is consistent across all routers.
Keep the reference consistent across the routing domain. Otherwise a gigabit link can cost 1 on one router and 10 on another, making metrics harder to predict. This mismatch alone does not prevent adjacency. Choose a reference that separates the link speeds in your design. For example, 10 000 Mbps gives 10 Gbps a cost of 1 and 1 Gbps a cost of 10. Integer rounding can still give similar speeds the same cost.
On a live network, treat a reference bandwidth change as planned work. Calculated interface costs can change on the affected router; new LSAs and SPF calculations can shift paths. During migration the routers use mixed references. It is far easier to set it before the first router goes into production.
Checking interface costs and the chosen path
The following excerpts use reference 1000 Mbps and no explicit cost override. Router links use broadcast OSPF here; the LAN-facing interface is passive.
R1#show ip ospf interface brief Interface PID Area IP Address/Mask Cost State Nbrs F/C Gi0/2 1 0 10.0.13.1/30 10 BDR 1/1 Gi0/1 1 0 10.0.12.1/30 1 BDR 1/1
R1#show ip route 192.168.4.0 Routing entry for 192.168.4.0/24 Known via "ospf 1", distance 110, metric 3, type intra area Last update from 10.0.12.2 on GigabitEthernet0/1, 00:01:15 ago Routing Descriptor Blocks: * 10.0.12.2, from 4.4.4.4, 00:01:15 ago, via GigabitEthernet0/1 Route metric is 3, traffic share count is 1
R1#show interfaces GigabitEthernet0/2 | include BW MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,
show ip ospf | include ReferenceRun in privileged EXEC mode on every router. With this lab's settings, look for Reference bandwidth unit is 1000 mbps; wording can vary by release.
When traffic takes the slow link
Use the four-router topology above. The top path is gigabit throughout; only R1→R3 uses 100 Mbps bandwidth. Changes below are calculations, not device configuration.
Top via R2: 1 + 1 + 1 = 3
Bottom via R3: 10 + 1 + 1 = 12
Installed next hop: R2 only · route metric 3
Destination 192.168.4.0/24 · R2 10.0.12.2 via Gi0/1.
router ospf 1
auto-cost reference-bandwidth 1000
exit
interface GigabitEthernet0/2
no ip ospf cost
exitR1 only, starting in global configuration mode. Apply the selected reference separately on R2, R3 and R4; the interface override shown applies only to R1. The link-down checkbox is not part of this configuration.
Steady-state illustration: all other links and the return path are available. Only comparable intra-area OSPF routes are considered. ECMP does not guarantee a 50/50 byte split or faster throughput for one transfer.
- Traffic is shared over a fast and a slow link. A low reference may make their costs equal. Check both totals and explicit overrides before planning a consistent reference change.
- Paths look odd or return a different way. Mixed references are one possible cause. Compare
show ip ospf | include Referenceand each outgoing interface cost rather than diagnosing the cause from the path alone. - Traffic goes one way and returns another. A one-sided
ip ospf costcan explain this, but other topology or routing differences can too. Asymmetry is not automatically a fault; inspect both directions. - A cost won't change. An
ip ospf coston the interface overrides both the reference bandwidth and thebandwidthcommand.
Try a cost change and explain the result
Use the four-router diagram in an isolated Cisco IOS or IOS XE lab. Start with all routers using reference bandwidth 1 000 Mbps, R1 Gi0/2 reporting 100 Mbps, and no explicit cost overrides. Interface names vary by image. These are documentation-based examples, not output captured from your devices. Begin at the privileged R1# prompt.
show ip route 192.168.4.0
show ip ospf interface GigabitEthernet0/2
configure terminal
interface GigabitEthernet0/2
ip ospf cost 1
end
show ip route 192.168.4.0Record the original next hop and cost. Then temporarily make R1's outgoing link to R3 cost 1. Both complete paths should now total 3 if the other costs match the diagram and multiple paths are permitted.
Look for next hops 10.0.12.2 and 10.0.13.2, both at metric 3. The change did not speed up the physical link; it only changed the routing decision. If only one next hop appears, check each outgoing cost and the process maximum-paths setting before repeating the change.
configure terminal
interface GigabitEthernet0/2
no ip ospf cost
end
show ip route 192.168.4.0Remove the temporary override. With the starting assumptions restored, R1's route should return to the cost-3 next hop through R2; the path through R3 totals 12.
Now remove the preferred link, then restore it
Keep that override removed. In the explorer above, select reference 1000 Mbps and explicit cost None, then check R1–R2 link down. The cost-3 path is unavailable, so the displayed next hop changes to R3 at cost 12. Uncheck it to restore R2. This is a steady-state calculation; it does not model the time required to detect a real failure and exchange updates.
To verify the same idea on your isolated four-router lab, temporarily shut R1's Gi0/1 interface. Keep console access so your connection does not depend on the link you are testing. This is an intentional interface outage, not a command needed merely to change a metric.
configure terminal
interface GigabitEthernet0/1
shutdown
end
show ip ospf neighbor
show ip route 192.168.4.0R1 privileged EXEC mode → global configuration → interface mode. After convergence, the R2 neighbour is absent and the route should use 10.0.13.2 through Gi0/2 at metric 12, assuming all remaining costs and links match the diagram.
configure terminal
interface GigabitEthernet0/1
no shutdown
end
show ip ospf neighbor
show ip route 192.168.4.0Restore the same interface. Allow its OSPF adjacency to reach Full and the route calculation to finish; then verify next hop 10.0.12.2 through Gi0/1 at metric 3. No OSPF process reset is needed.
If the backup route never appears, check R1's Full adjacency with R3, the R3–R4 link, and R4's advertisement of 192.168.4.0/24. A high-cost path is useful only while it remains reachable. If both paths are lost, raising or lowering a metric cannot create connectivity.
Cost rules to remember
- For these Cisco examples, calculated interface cost = reference bandwidth ÷ interface bandwidth, using the same units; discard fractions, minimum 1. Verify platform limits (interface cost range 1–65 535 here).
- Path cost = sum of outgoing interface costs, including the destination LAN interface.
- The default 100 Mbps reference makes every link of 100 Mbps or more cost 1; raise it on every router.
ip ospf costoverrides the calculated cost;bandwidthchanges the calculation input, not the physical speed.- Equal eligible path costs can install multiple next hops, subject to platform limits and maximum-paths.
Test yourself on OSPF cost
Sources: Cisco OSPF FAQ: reference bandwidth and CEF; Cisco IOS OSPF command reference: auto-cost and ip ospf cost; Cisco interface reference: bandwidth; RFC 2328, sections 12.4.1 and 16.1: router-LSAs and intra-area paths. IOS-style outputs are illustrative; verify platform limits and interface bandwidth on your release.
The reference bandwidth is the default. What is the cost of a 10 Mbps Ethernet interface?
With a 1 000 Mbps reference, R1 has paths to LAN B of cost 1 + 1 + 1 and 10 + 1 + 1. Which does it use?
You type auto-cost reference-bandwidth 10000 on R1 only. What is the likely result?
An interface has bandwidth 100000 and ip ospf cost 5. The reference is 1 000 Mbps. What is its cost?