Traffic takes the wrong path through your OSPF network. How do you steer it?
Show the answer
Say this first
First check the costs along both paths with show ip ospf interface brief and the route metric. Then set
ip ospf cost on the interfaces that should be less attractive, on the router where the traffic leaves,
in both directions if the return path matters. Fix a wrong reference bandwidth before adding manual costs.
Go deeper
Cost is outbound
The cost of a link counts in the direction the router sends traffic. To make R1 avoid a link, raise the cost on R1's interface. To make the return traffic avoid it too, raise it on the far end as well.
Tools, from cleanest to bluntest
- Reference bandwidth set right everywhere, so speed is reflected automatically.
ip ospf cost <1-65535>on specific interfaces. Overrides the calculation, affects only OSPF.bandwidthon the interface. Changes the calculation but also EIGRP and QoS. Avoid for this.- Area design. Intra-area beats inter-area regardless of cost, so a link in the wrong area wins anyway.
Check
R1# show ip ospf interface brief
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Lo0 1 0 1.1.1.1/32 1 LOOP 0/0
Gi0/0/1 1 0 10.0.13.1/30 100 P2P 1/1
Gi0/0/0 1 0 10.0.12.1/30 10 P2P 1/1They will ask next
Two paths have equal cost. What does OSPF do?
It installs both, up to
maximum-paths(4 by default on IOS), and CEF load-shares per flow.Can you set a cost per neighbor?
Only on point-to-multipoint networks, with
neighbor <ip> cost <n>. Normally cost is per interface.
Traps
- Changing cost only on one end and expecting symmetric traffic.