Networking

How to configure equal-cost multi-path in OSPF

Equal-cost multi-path allows a router to insert more than one path to a destination in the routing table to enable load balancing. Here's how ECMP works and how to configure it in OSPF.

Equal-cost multi-path (ECMP) is a strategy used in routing to forward traffic to a destination over multiple best paths. These best paths have calculated the same metric according to the routing protocol in use. For example, if there were two paths to network Z and the first path (A-B-C-Z) had a calculated metric of 40, while the second path (A-D-E-F-Z) had a calculated metric of 60, the first path would be chosen as the best path and that single route would be placed in the routing table. However, if the calculated metric of the second path (A-D-E-F-Z) had a calculated metric of 40, then it too would be considered the best path. A tie would occur and both routes could be placed in the routing table. At this point the router will load-share traffic over both next hops when traffic is destine for network Z.

Several routing protocols support ECMP. Let's take a look at how OSPF uses ECMP and how it is configured.

SEE: Network security policy (Tech Pro Research)

ECMP in OSPFv2

OSPFv2 is the version of OSPF used for routing IPv4 traffic. To configure ECMP in an OSPFv2 network you would use the maximum-paths command and specify how many equal-cost paths the router should use. This value has traditionally been set to 4, however, in newer Cisco IOS versions you can configure up to 32.

router ospf 1
maximum-paths 2

ECMP in OSPFv3

OSPFv3 is the version of OSPF used for routing IPv6 traffic. Most of the underlying OSPF functionality stays the same. In fact, the configuration of ECMP stays mostly the same. Inside the OSPF process you define ECMP using the maximum-paths command.

ipv6 router ospf 1
maximum-paths 2

More on ECMP

Maximum-path values apply to each router individually so you will need to configure the setting on each router in the network.

With ECMP enabled you'll now see two next hops in the routing table for a destination that has two paths with the same metric. The following is an example output from OSPF:

<code>ABR5#show ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP    D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area     N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2    E1 - OSPF external type 1, E2 - OSPF external type 2    i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2    ia - IS-IS inter area, * - candidate default, U - per-user static route    o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP    a - application route  Gateway of last resort is not set    10.0.0.0/8 is variably subnetted, 27 subnets, 2 masks O IA     10.0.0.4/30 [110/3] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 O IA     10.0.0.8/30 [110/2] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 O        10.0.0.12/30 [110/2] via 10.0.0.41, 00:00:21, GigabitEthernet0/3   [110/2] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 O        10.0.0.16/30 [110/2] via 10.0.0.65, 00:00:21, GigabitEthernet0/4   [110/2] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 O        10.0.0.20/30 [110/2] via 10.0.0.73, 00:00:21, GigabitEthernet0/2   [110/2] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 C        10.0.0.24/30 is directly connected, GigabitEthernet0/1 L        10.0.0.26/32 is directly connected, GigabitEthernet0/1 O IA     10.0.0.28/30 [110/2] via 10.0.0.41, 00:00:21, GigabitEthernet0/3 O        10.0.0.32/30 [110/2] via 10.0.0.65, 00:00:21, GigabitEthernet0/4   [110/2] via 10.0.0.41, 00:00:21, GigabitEthernet0/3 O        10.0.0.36/30 [110/2] via 10.0.0.73, 00:00:21, GigabitEthernet0/2   [110/2] via 10.0.0.41, 00:00:21, GigabitEthernet0/3 C        10.0.0.40/30 is directly connected, GigabitEthernet0/3 L        10.0.0.42/32 is directly connected, GigabitEthernet0/3 O IA     10.0.0.44/30 [110/2] via 10.0.0.65, 00:00:11, GigabitEthernet0/4 O        10.0.0.48/30 [110/2] via 10.0.0.73, 00:00:21, GigabitEthernet0/2   [110/2] via 10.0.0.65, 00:00:21, GigabitEthernet0/4 O IA     10.0.0.52/30 [110/2] via 10.0.0.73, 00:00:21, GigabitEthernet0/2 O        10.0.0.56/30 [110/2] via 10.0.0.65, 00:00:21, GigabitEthernet0/4 O IA     10.0.0.60/30 [110/3] via 10.0.0.73, 00:00:21, GigabitEthernet0/2   [110/3] via 10.0.0.65, 00:00:11, GigabitEthernet0/4 C        10.0.0.64/30 is directly connected, GigabitEthernet0/4 L        10.0.0.66/32 is directly connected, GigabitEthernet0/4 O        10.0.0.68/30 [110/2] via 10.0.0.73, 00:00:21, GigabitEthernet0/2 C        10.0.0.72/30 is directly connected, GigabitEthernet0/2 L        10.0.0.74/32 is directly connected, GigabitEthernet0/2 C        10.0.0.76/30 is directly connected, GigabitEthernet0/5 L        10.0.0.77/32 is directly connected, GigabitEthernet0/5 C        10.0.0.80/30 is directly connected, GigabitEthernet0/6 L        10.0.0.81/32 is directly connected, GigabitEthernet0/6 O        10.0.0.84/30 [110/2] via 10.0.0.78, 00:00:21, GigabitEthernet0/5   192.168.0.0/32 is subnetted, 9 subnets O        192.168.0.1 [110/2] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 O IA     192.168.0.2 [110/3] via 10.0.0.25, 00:00:21, GigabitEthernet0/1 O IA     192.168.0.3 [110/3] via 10.0.0.41, 00:00:20, GigabitEthernet0/3 O        192.168.0.4 [110/2] via 10.0.0.41, 00:00:21, GigabitEthernet0/3 O        192.168.0.5 [110/2] via 10.0.0.65, 00:00:21, GigabitEthernet0/4 O IA     192.168.0.6 [110/3] via 10.0.0.73, 00:00:21, GigabitEthernet0/2  [110/3] via 10.0.0.65, 00:00:11, GigabitEthernet0/4 O        192.168.0.8 [110/2] via 10.0.0.73, 00:00:21, GigabitEthernet0/2 C        192.168.0.9 is directly connected, Loopback0 O        192.168.0.10 [110/2] via 10.0.0.78, 00:00:21, GigabitEthernet0/5 ABR5#

Note that there are several prefixes in the routing table that can take more than one path. Specifically 10.0.0.12/30 can be reached via 10.0.0.41 and via 10.0.0.25. Packets will be load shared over each path in a round robin.

ECMP in BGP

BGP also supports multi-path capabilities. One difference between the two is that BGP requires two commands to achieve this routing capability; one for eBGP and one for iBGP peerings.

Final Thoughts

ECMP is something that's necessary in today's networks. It provides a service that is absolutely required with the existence of multiple links and resilient routing designs. Understanding how it works and how to configure it is something that should be in every network engineers repetoire.

Also see:

About Brandon Carroll

Brandon Carroll has been in the industry since the late 90s specializing in data networking and network security in the enterprise and data center. Brandon holds the CCIE in security and is a published author in network security.

Editor's Picks

Free Newsletters, In your Inbox