Cost and ECMP
Use consistent cost policy and verify equal next hops without promising equal traffic.
Understand
Automatic interface cost is based on reference bandwidth divided by interface bandwidth, with a minimum cost of 1 on common router implementations. A legacy 100-Mbps reference collapses 100-Mbps, 1-Gbps and 10-Gbps links to cost 1. Configure a consistent reference across the domain when using automatic costs; it does not negotiate through Hellos.
An explicit ip ospf cost overrides automatic calculation. Our baselines use explicit costs, so changing only auto-cost reference-bandwidth will not change them. Equal-cost multipath installs eligible equal routes up to maximum-paths and platform limits. Forwarding often hashes flows; two next hops do not imply a 50/50 byte split or per-packet alternation.
Lab setup
Use a fresh lab for this lesson; changes from other lessons are not cumulative. All outputs are illustrative excerpts, not recorded router tests. Transit cost is explicitly 10 and Loopback0 cost is 1. Interface names may vary by image.
| Router | Interface | IPv4 address | Area |
|---|---|---|---|
| R1 | Gi1 | 192.0.2.1/30 | 0 |
| R2 | Gi1 | 192.0.2.2/30 | 0 |
| R1 | Gi2 | 192.0.2.5/30 | 0 |
| R3 | Gi1 | 192.0.2.6/30 | 0 |
| R2 | Gi2 | 192.0.2.9/30 | 0 |
| R3 | Gi2 | 192.0.2.10/30 | 0 |
Loopback0 is 10.255.0.<router number>/32; area assignments: R1: area 0, R2: area 0, R3: area 0.
Complete baseline configurations
R1
configure terminal
hostname R1
router ospf 1
router-id 10.255.0.1
passive-interface Loopback0
exit
interface Loopback0
ip address 10.255.0.1 255.255.255.255
ip ospf 1 area 0
ip ospf cost 1
exit
interface GigabitEthernet1
ip address 192.0.2.1 255.255.255.252
ip ospf network point-to-point
ip ospf cost 10
ip ospf 1 area 0
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.5 255.255.255.252
ip ospf network point-to-point
ip ospf cost 10
ip ospf 1 area 0
no shutdown
exit
endR2
configure terminal
hostname R2
router ospf 1
router-id 10.255.0.2
passive-interface Loopback0
exit
interface Loopback0
ip address 10.255.0.2 255.255.255.255
ip ospf 1 area 0
ip ospf cost 1
exit
interface GigabitEthernet1
ip address 192.0.2.2 255.255.255.252
ip ospf network point-to-point
ip ospf cost 10
ip ospf 1 area 0
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.9 255.255.255.252
ip ospf network point-to-point
ip ospf cost 10
ip ospf 1 area 0
no shutdown
exit
endR3
configure terminal
hostname R3
router ospf 1
router-id 10.255.0.3
passive-interface Loopback0
exit
interface Loopback0
ip address 10.255.0.3 255.255.255.255
ip ospf 1 area 0
ip ospf cost 1
exit
interface GigabitEthernet1
ip address 192.0.2.6 255.255.255.252
ip ospf network point-to-point
ip ospf cost 10
ip ospf 1 area 0
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.10 255.255.255.252
ip ospf network point-to-point
ip ospf cost 10
ip ospf 1 area 0
no shutdown
exit
endApply
Make the direct R1→R3 transit cost 20, equal to the two-link path via R2. Allow two next hops.
R1
configure terminal
router ospf 1
maximum-paths 2
exit
interface GigabitEthernet2
ip ospf cost 20
endVerify and interpret
R1# show ip route 10.255.0.3
Routing entry for 10.255.0.3/32
Known via "ospf 1", distance 110, metric 21, type intra area
* 192.0.2.2, via GigabitEthernet1
* 192.0.2.6, via GigabitEthernet2Both paths total 21 including R3’s loopback. A single ping flow may use just one next hop.
For a separate automatic-cost experiment, restore the fresh triangle, remove explicit transit costs on every router, and apply the following reference on every router. Verify each interface’s configured bandwidth and resulting OSPF cost; changing bandwidth metadata does not change physical line speed.
Every router · automatic-cost experiment
configure terminal
router ospf 1
auto-cost reference-bandwidth 10000
exit
interface GigabitEthernet1
no ip ospf cost
exit
interface GigabitEthernet2
no ip ospf cost
endFor a 1-Gbps interface with 10000-Mbps reference, expected cost is 10; for 10-Gbps it is 1. Restore the complete explicit-cost baseline before another lesson.
Technical references
Key Takeaways
- Use one deliberate reference-bandwidth policy.
- Explicit interface cost overrides automatic cost.
- ECMP needs equal total path costs and an adequate path limit.
- ECMP does not guarantee equal bytes across links.
- Check actual interface bandwidth and installed next hops.