# Lab1 ECMP

Load **unix:lab1.init.cfg**

```
configure replace unix:lab1.init.cfg
```

The idea behind these labs is that R6 is advertising 192.0.2.6/32 and 2001:db8::6/128. It is multi-homed to R4 and R5. We will use various techniques to achieve load balancing and failover.

This first lab requires you to configure ECMP. Currently R2 and R3 are using R4 for egress due to its lower RID. R6 is using R4 for this reason as well. **Configure the fewest number of routers so that traffic from R1 to R6 is load balanced through R4 and R5, and return traffic from R6 is likewise load balanced.**

## Answer <a href="#id-3d2fe3c4-64bd-4a78-9d8f-a4eac0fd7c57" id="id-3d2fe3c4-64bd-4a78-9d8f-a4eac0fd7c57"></a>

<https://www.youtube.com/watch?v=AJXdxembu_8&list=PL3Y9eZjZCcsejbVWD3wJIePqe3NiImqxB&index=2>

```
#R3
router bgp 65000
 add ipv4
  maximum-paths ibgp 2
 add ipv6
  maximum-paths ibgp 2

#R6
router bgp 65006
 add ipv4
  maximum-paths 2
 add ipv6
  maximum-paths 2
```

## Explanation <a href="#id-7233c18d-4f12-4f10-8d2d-52986eb46767" id="id-7233c18d-4f12-4f10-8d2d-52986eb46767"></a>

The maximum-paths feature allows multiple BGP paths to be used for load balancing if all criteria up to the IGP metric of the nexthop match. Additionally, the AS\_PATH content must be the same.

Enabling ECMP for only iBGP routes is done using:

```
router bgp 65000
 maximum-paths ibgp num
```

Enabling ECMP for only eBGP routes is done using:

```
router bgp 65000
 maximum-paths num
```

Enabling ECMP for both iBGP and eBGP routes can be done using the following command, but can introduce loops:

```
router bgp 65000
 maximum-paths eibgp 2
%BGP: This may cause traffic loop if not used properly (command accepted)
```

## Verification <a href="#id-8d1d4d51-54b9-4bf3-8279-94a21722a8e7" id="id-8d1d4d51-54b9-4bf3-8279-94a21722a8e7"></a>

On R3 we can see that it accepted the path via R5 as a multipath candidate. The path via R4 is still best, and is the one path that would be advertised to eBGP peers.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F10iCd0MVoR7f8d4jjso9%2Fimage.png?alt=media&#x26;token=851527ca-b243-417f-8b0a-9e2b188178cc" alt=""><figcaption></figcaption></figure></div>

We can verify in the FIB that traffic is being load shared:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FSS9osaeo0j6UKtv8J6SV%2Fimage.png?alt=media&#x26;token=b00e505f-bea8-46c9-9dd0-4208083b5727" alt=""><figcaption></figcaption></figure></div>

On R6, we can similarly verify outgoing traffic is load shared among R4 and R5.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FI1vVd9L2HuO007CjegWL%2Fimage.png?alt=media&#x26;token=3b686c6f-93f1-4d91-978f-6cb0ae20f765" alt=""><figcaption></figcaption></figure></div>

The reason that we do not need to enable iBGP multipath on R2, is that it will always use R3 to get to R4 and R5, so enabling multipath does not technically achieve anything. It can be done, but the result is the same with or without it.
