How does OSPF load balance, and can it do unequal-cost load balancing?
Show the answer
Say this first
OSPF installs equal-cost paths only, up to maximum-paths, which is 4 by default on IOS. CEF then
shares traffic per flow by hashing source and destination addresses. OSPF cannot do unequal-cost load
balancing like EIGRP variance. You either make the costs equal or use something above OSPF.
Go deeper
Config and check
router ospf 1
maximum-paths 8R1# show ip route 10.30.0.0
Routing entry for 10.30.0.0/24
Known via "ospf 1", distance 110, metric 21, type intra area
Last update from 10.0.13.3 on GigabitEthernet0/0/1, 00:04:10 ago
Routing Descriptor Blocks:
* 10.0.12.2, from 3.3.3.3, 00:04:10 ago, via GigabitEthernet0/0/0
Route metric is 21, traffic share count is 1
10.0.13.3, from 3.3.3.3, 00:04:10 ago, via GigabitEthernet0/0/1
Route metric is 21, traffic share count is 1Per flow, not per packet
The default CEF hash keeps a flow on one path, which avoids reordering. One big flow still uses one link.
show ip cef exact-route <src> <dst> shows which path a given pair takes.
Wanting unequal cost
Options are equal costs with links of different sizes accepted as is, a bundle (EtherChannel), MPLS TE, or a different protocol. Changing costs to fake it only moves all traffic to one path.
They will ask next
Two equal paths, but one link is 10G and the other 1G. What happens?
With the default reference bandwidth both cost 1, so OSPF splits flows evenly and the 1G link congests. Raising the reference bandwidth makes the costs differ and OSPF uses only the 10G path.
Traps
- Saying OSPF supports variance. That is EIGRP.