Equal cost multi-path routing (ECMP)
The ECMP feature allows OSPF to add routes with multiple next-hop addresses and with equal costs to a given destination in the forwarding information base (FIB) on the routing switch. For example, if you display the IP route table by entering the
show ip route
command, multiple next-hop routers are listed for the same destination network (21.0.9.0/24) as shown in the following example:
Example of show ip route command output with multiple next-hop routes
switch show ip route IP Route Entries Destination Gateway VLAN Type Sub-Type Metric Dist. ------------------ --------------- ---- --------- ---------- ---------- ----- 1.0.0.0/8 10.0.8.1 1 static 1 1 10.0.8.0/21 DEFAULT_VLAN 1 connected 1 0 12.0.9.0/24 VLAN3 3 connected 1 0 15.0.0.0/8 10.0.8.1 1 static 1 1 21.0.9.0/24 162.130.101.2 2 ospf IntraArea 2 110 21.0.9.0/24 162.130.101.3 2 ospf IntraArea 2 110 21.0.9.0/24 162.130.101.4 2 ospf IntraArea 2 110 127.0.0.0/8 reject static 0 0 127.0.0.1/32 lo0 connected 1 0 162.130.101.0/24 VLAN2 2 connected 1 0
Intra-area (routes to the destination in the same OSPF area)
Inter-area (routes to the destination through another OSPF area)
External (routes to the destination through another AS)
Multiple ECMP next-hop routes cannot be a mixture of intra-area, inter-area, and external routes. In the example above, the multiple next-hop routes to network 21.0.9.0/24 are all intra-area.
Intra-area routes are preferred to inter-area routes.
Inter-area routes are preferred to external routes through a neighboring AS.
In addition, ECMP ensures that all traffic forwarded to a given host address follows the same path, which is selected from the possible next-hop routes.
For example, in the following figure, the ECMP inter-area routes to destination network 10.10.10.0/24 consist of the following next-hop gateway addresses: 12.0.9.2, 13.0.9.3, and 14.0.9.4.
However, the forwarding software distributes traffic across the three possible next-hop routes in such a way that all traffic for a specific host is sent to the same next-hop router.
Traffic to host 10.10.0.1 passes through next-hop router 12.0.9.2.
Traffic to host 10.10.0.2 passes through next-hop router 13.0.9.3.
Traffic to host 10.10.0.3 passes through next-hop router 12.0.9.2.
Traffic to host 10.10.0.4 passes through next-hop router 14.0.9.4.