Cost and ECMP
Each OSPF interface has a cost, and a route's metric is the sum of the outgoing interface costs along the path. Lower is better. Costs are per direction: R1's cost towards R2 can differ from R2's cost towards R1, which can make traffic paths asymmetric.
By default the cost is derived from bandwidth:
cost = reference bandwidth ÷ interface bandwidth (minimum 1)
The default reference bandwidth is 100 Mbps — a value from the 1990s. With it:
| Interface | Cost with 100 Mbps reference | Cost with 100 Gbps reference |
|---|---|---|
| 10 Mbps | 10 | 10000 |
| 100 Mbps | 1 | 1000 |
| 1 Gbps | 1 | 100 |
| 10 Gbps | 1 | 10 |
| 100 Gbps | 1 | 1 |
Everything from 100 Mbps upward costs 1, so OSPF can't tell a 1G link from a 100G link and picks paths by hop count. Fix it with auto-cost reference-bandwidth 100000 (in Mbps) — on every router, or costs become inconsistent — or set ip ospf cost explicitly on each interface, which many operators prefer because the design is then visible in the config.
Equal-cost multipath
When several paths have exactly the same total cost, OSPF installs all of them (up to a platform limit, maximum-paths in FRR). The forwarding plane hashes each flow onto one of the next hops, so a single TCP connection stays on one path while load spreads across many flows. Data-centre designs depend on this.
Check your understanding
With the default 100 Mbps reference bandwidth, a router has two paths to a destination: three hops of 100 Gbps links, or two hops of 1 Gbps links. Which does OSPF use?
- The 100 Gbps path, because it is faster
- The 1 Gbps path, because its total cost is 2 versus 3
- Both, with ECMP