Equal Cost Multi-Path (ECMP) Explanation & Configuration

Equal Cost Multi-Path or ECMP is a routing strategy where packets towards a single destination IP address are load-balanced over multiple best paths with equal metrics.

 

Cisco Routing Concepts

How does a Cisco Layer 3 device, such as a router, decides which route to use?

  1. Prefix length – the longest prefix match is always preferred. For example, a /24 route wins over a /16 route.
  2. Administrative Distance (AD) – if the routes have the same prefix lengths and are using different routing protocols, then the route with the lowest Administrative Distance wins. For example, OSPF routes are more preferred than RIP routes by default.
  3. Metric – if the routes have the same prefix length and administrative distance, then it will come down to the metrics. So the router learns about multiple different paths going to the same destination, using the same routing protocol, a measure called metric is used to decide. The path with lower metric wins.

Now, what happens if a routing table has multiple paths with identical metrics (equal cost) to the exact destination network? Equal Cost Multi-Path (ECMP) or load balancing occurs.

 

Equal Cost Multi-Path (ECMP) on Dynamic Routes

Let’s see how Equal Cost Multi-Path or ECMP works on dynamic routing protocols. In our example, we’ll use EIGRP going to the 10.10.40.100, which is in R4 LAN.

ecmp

 

Let’s configure all of the IP addresses on our devices first:

R1

R1#conf t
R1(config)#interface GigabitEthernet0/0
R1(config-if)#ip address 10.10.20.1 255.255.255.252
R1(config-if)#no shutdown
R1(config-if)#interface GigabitEthernet0/1
R1(config-if)#ip address 10.10.30.1 255.255.255.252
R1(config-if)#no shutdown

R2

R2#conf t
R2(config)#interface GigabitEthernet0/0
R2(config-if)#ip address 10.10.20.2 255.255.255.252
R2(config-if)#no shutdown
R2(config-if)#interface GigabitEthernet0/1
R2(config-if)#ip address 10.10.20.5 255.255.255.252
R2(config-if)#no shutdown

R3

R3#conf t
R3(config)#interface GigabitEthernet0/0
R3(config-if)#ip address 10.10.30.5 255.255.255.252
R3(config-if)#no shutdown
R3(config-if)#interface GigabitEthernet0/1
R3(config-if)#ip address 10.10.30.2 255.255.255.252
R3(config-if)#no shutdown

R4

R4#conf t
R4(config)#interface GigabitEthernet0/0
R4(config-if)#ip address 10.10.40.1 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#interface GigabitEthernet0/1
R4(config-if)#ip address 10.10.30.6 255.255.255.252
R4(config-if)#no shutdown
R4(config-if)#interface GigabitEthernet0/2
R4(config-if)#ip address 10.10.20.6 255.255.255.252
R4(config-if)#no shutdown

 

Next, we enable EIGRP on all routers.

R1

R1(config)#router eigrp 1
R1(config-router)#network 10.0.0.0
R1(config-router)#redistribute connected

R2

R2(config)#router eigrp 1
R2(config-router)#network 10.0.0.0
R2(config-router)#redistribute connected

R3

R3(config)#router eigrp 1
R3(config-router)#network 10.0.0.0
R3(config-router)#redistribute connected

R4

R4(config)#router eigrp 1
R4(config-router)#network 10.0.0.0
R4(config-router)#redistribute connected

We then check if EIGRP neighbor adjacencies are up on all routers.

R1#sh ip eigrp neighbors

EIGRP-IPv4 Neighbors for AS(1)
H   Address                 Interface              Hold Uptime   SRTT   RTO  Q  Seq
                                                   (sec)         (ms)       Cnt Num
1   10.10.30.2              Gi0/1                    11 00:54:46    5   100  0  30
0   10.10.20.2              Gi0/0                    14 00:57:23    8   100  0  22

 

Let’s do the ‘show ip route‘ command to view the routing table.

R1#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
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1 subnets
C        1.1.1.1 is directly connected, Loopback1
      2.0.0.0/32 is subnetted, 1 subnets
C        2.2.2.2 is directly connected, Loopback2
      10.0.0.0/8 is variably subnetted, 7 subnets, 3 masks
C        10.10.20.0/30 is directly connected, GigabitEthernet0/0
L        10.10.20.1/32 is directly connected, GigabitEthernet0/0
D        10.10.20.4/30 [90/3072] via 10.10.20.2, 00:58:53, GigabitEthernet0/0
C        10.10.30.0/30 is directly connected, GigabitEthernet0/1
L        10.10.30.1/32 is directly connected, GigabitEthernet0/1
D        10.10.30.4/30 [90/3072] via 10.10.30.2, 00:58:53, GigabitEthernet0/1
D        10.10.40.0/24 [90/3328] via 10.10.30.2, 00:58:53, GigabitEthernet0/1
                       [90/3328] via 10.10.20.2, 00:58:53, GigabitEthernet0/0

We can see that both R2 and R3 advertised routes are installed in R1’s routing table. The equal cost routes have the same AD and metrics.

 

Equal Cost Multi-Path (ECMP) on Static Routes

Now, let’s try ECMP using static routes. On R1, let’s remove EIGRP, and then we’ll add two static routes with the next hop addresses of 10.10.30.2 and 10.10.20.2, via R2 and R3. It doesn’t have to be the same next hop. This will create multiple paths going to 10.10.40.0/24.

R1(config)#no router eigrp 1
R1(config)#ip route 10.10.40.0 255.255.255.0 10.10.30.2
R1(config)#ip route 10.10.40.0 255.255.255.0 10.10.20.2

 

We can verify our routes by checking the routing table again. We can see that the ECMP routes from R2 and R3 are installed in our route table.

R1#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
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1 subnets
C        1.1.1.1 is directly connected, Loopback1
      2.0.0.0/32 is subnetted, 1 subnets
C        2.2.2.2 is directly connected, Loopback2
      10.0.0.0/8 is variably subnetted, 5 subnets, 3 masks
C        10.10.20.0/30 is directly connected, GigabitEthernet0/0
L        10.10.20.1/32 is directly connected, GigabitEthernet0/0
C        10.10.30.0/30 is directly connected, GigabitEthernet0/1
L        10.10.30.1/32 is directly connected, GigabitEthernet0/1
S        10.10.40.0/24 [1/0] via 10.10.30.2
                       [1/0] via 10.10.20.2

 

Equal Cost Multi-Path (ECMP) Load Balancing Methods

One more thing that I want to add about ECMP load balancing is the load balancing decisions. By default, it’s set as Per-Destination Load Balancing.

Per-Destination Load Balancing – packets for a given source and destination host pairs are guaranteed to take the same path, even if multiple ECMP paths are available. (Per-flow load balancing)

Per-Packet Load Balancing – it uses the round-robin method to determine which path each packet takes to the destination IP. This is inappropriate for certain types of traffic, such as Voice over IP (VoIP), which depends on the packets arriving at the destination in sequence.

 

We can check which Equal Cost Multi-Path (ECMP) load balancing method is in effect by using the ‘show ip cef‘ command:

R1#sh ip cef 10.10.40.100 detail
10.10.40.0/24, epoch 0, per-destination sharing
  nexthop 10.10.20.2 GigabitEthernet0/0
  nexthop 10.10.30.2 GigabitEthernet0/1

 

We can change how ECMP load balancing works on the interface config mode:

R1(config)#int gi0/0
R1(config-if)#ip load-sharing ?
per-destination Deterministic distribution
per-packet Random distribution

 


Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book.

We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training: