A real-life situation
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. show ip route on R1 shows two routes to LAN B with the same cost: OSPF is sending half the traffic over the slow link. It can't tell the two links apart, and this lesson shows why.
What OSPF cost is
Each interface gets a cost from one simple division:
cost = reference bandwidth ÷ interface bandwidth
The result is rounded down and is never less than 1. The reference bandwidth is 100 Mbps unless you change it. That made sense when 100 Mbps was fast, but today it means:
| 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 |
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 needs 10 000 Mbps or more.
How path cost adds up
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.
- 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.
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). OSPF installs up to 4 equal paths by default (change it with maximum-paths under router ospf). ECMP is useful when the paths really are equal, and harmful when they only look equal.
How to configure it on Cisco IOS
There are three ways to influence cost. In order of priority, highest first:
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.
2. Change the bandwidth the formula uses
interface GigabitEthernet0/2
bandwidth 100000In kbps (100 000 kbps = 100 Mbps). The formula now divides by 100 Mbps. Use it when the interface runs faster than the real service, for example a gigabit port connected to a 100 Mbps WAN circuit. Other features read this value too.
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.
The reference must be the same on every router. Otherwise one router thinks a gigabit link costs 1 and another thinks it costs 10, and their path choices stop making sense together. Choose a value at least as high as your fastest link, so the fastest link costs 1 and everything slower costs more.
How to verify it
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 P2P 1/1 Gi0/1 1 0 10.0.12.1/30 1 P2P 1/1 Gi0/0 1 0 192.168.1.1/24 1 DR 0/0
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,
bandwidth command.show ip ospf | include ReferencePrints: Reference bandwidth unit is 1000 mbps. Check it on every router.
What goes wrong and how to troubleshoot it
- Traffic is shared over a fast and a slow link. The default reference makes them equal. Raise
auto-cost reference-bandwidtheverywhere. - Path choices change depending on which router you ask. The reference bandwidth differs between routers. Compare
show ip ospf | include Reference. - Traffic goes one way and returns another.
ip ospf costwas set on one end of a link only. That isn't wrong, but it should be deliberate. - A cost won't change. An
ip ospf coston the interface overrides both the reference bandwidth and thebandwidthcommand.
Common mistakes
- Counting incoming interface costs. Only outgoing interfaces count.
- Forgetting the last router's LAN interface when adding up a path.
- Mixing units:
auto-cost reference-bandwidthis in Mbps,bandwidthis in kbps. - Changing the reference bandwidth on one router only.
- Thinking
bandwidthchanges the real speed of the interface.
💡 Exam tip: be fast at 100 ÷ bandwidth in Mbps (and at other reference values), at adding path costs from a diagram, and at reading [110/3] as distance 110, cost 3. Know the three commands and that ip ospf cost wins over the other two.
Key takeaways
- Interface cost = reference bandwidth ÷ interface bandwidth, rounded down, minimum 1, maximum 65 535.
- 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 costoverridesbandwidth, which overrides the real speed.- Equal total costs give ECMP: up to 4 paths by default.
Check yourself
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?