How is OSPF cost calculated, and why do people raise the reference bandwidth?
Show the answer
Say this first
Cost is reference bandwidth divided by interface bandwidth, rounded down, with a minimum of 1. The IOS
default reference is 100 Mbps, so FastEthernet, 1G, 10G and 100G all cost 1 and OSPF cannot tell them apart.
I raise it with auto-cost reference-bandwidth to above the fastest link, the same value on every router.
Go deeper
With the default of 100 Mbps
| Interface | Bandwidth | Cost |
|---|---|---|
| Ethernet | 10 Mbps | 10 |
| FastEthernet | 100 Mbps | 1 |
| GigabitEthernet | 1 Gbps | 1 |
| TenGigabitEthernet | 10 Gbps | 1 |
With auto-cost reference-bandwidth 100000 (100 Gbps)
| Interface | Cost |
|---|---|
| 100G | 1 |
| 40G | 2 |
| 10G | 10 |
| 1G | 100 |
| 100M | 1000 |
router ospf 1
auto-cost reference-bandwidth 100000
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.The value is in Mbps. Interface cost tops out at 65535.
Why every router must match
Each router computes the cost of its own outgoing links. If R1 uses 100000 and R2 uses 100, R1's 10G links cost 10 and R2's cost 1, and paths become asymmetric and odd. Nothing warns you across routers.
Other platforms
Junos also defaults to 100 Mbps (reference-bandwidth under protocols ospf). NX-OS defaults to 40 Gbps.
They will ask next
Where does the interface bandwidth come from?
The
bandwidthvalue on the interface, which defaults to the negotiated speed on Ethernet. Changingbandwidthalso changes EIGRP metrics and QoS percentages, so for OSPF I preferip ospf cost.
Traps
- Saying cost is based on delay or load. OSPF cost only uses bandwidth, or a value you set.
- Changing the reference bandwidth on a few routers and calling it done.