# Some problems with ECMP



## pavjke (Apr 20, 2022)

Hi folks, I'm new in FreeBSD world and I need help. 

I've a server at FreeBSD with two uplinks which connected to switching fabric. Communication between them is organizing by BGP. Server uses FRR. I want to use ECMP for load sharing between uplinks. All routes have the same metric. Currently routing table looks like:

```
show ip route

B>* 0.0.0.0/0 [20/0] via x.x.0.20, ix1_vlan1, weight 1, 01w0d13h
  *                                 via x.x.1.22, ix0_vlan1, weight 1, 01w0d13h
B>* 10.x.x.0/26 [20/0] via x.x.0.5, ix1_vlan10, weight 1, 01w0d13h
  *                       via x.x.1.5, ix0_vlan10, weight 1, 01w0d13h
```


```
netstat -r

default            x.x.0.20       UG1    ix1_vlan
default            x.x.1.22       UG1    ix0_vlan
10.x.x.0/26     x.x.1.5        UG1    ix0_vlan
10.x.x.0/26     x.x.0.5        UG1    ix1_vlan
```

When only one of uplinks is UP - everything is OK. But when two - I'd problems with random disconnects. In traffic dump we can see random RST packets because server are sent some packets through another link. Can you help me or tell me where I can read more about how ECMP works in FreeBSD? 

I'm especially interested about:
- Which hash algorithms FreeBSD using is and how traffic will be processing?
- How I can check ECMP mode which will be using FreeBSD for sharing traffic (per-packets/per-flow)?


I'm using a 13.0-STABLE FreeBSD. Scheme at attachment.


----------



## VladiBG (Apr 20, 2022)

Select either static routes or OSPF (frr) not both. Check this example: https://bsdrp.net/documentation/examples/ecmp


----------



## pavjke (Apr 21, 2022)

VladiBG thank you so much for your attention to my question and for sharing interesting information. This answers at some of my questions. But I would still like to know where I could read more about how the ECMP protocol is implemented in FreeBSD? Which setting in the config file (zebra, frr or something else) is responsible for ECMP balancing mode, ie per-packet or per-flow? I don't use static routing. Maybe in my frr config something are missing/wrong?

frr version 7.5.1
frr defaults traditional
hostname xxxxx
log syslog notifications
!
router bgp xxxx
 no bgp ebgp-requires-policy
 bgp bestpath as-path multipath-relax
 neighbor x.x.0.20 remote-as xxxx
 neighbor x.x.0.20 bfd
 neighbor x.x.1.22 remote-as xxxx
 neighbor x.x.1.22 bfd
 neighbor x.x.0.5 remote-as xxxx
 neighbor x.x.0.5 bfd
 neighbor x.x.1.5 remote-as xxxx
 neighbor x.x.1.5 bfd
 !
 address-family ipv4 unicast
  redistribute connected
  neighbor x.x.0.20 next-hop-self
  neighbor x.x.0.20 route-map s1_lan_out out
  neighbor x.x.1.22 next-hop-self
  neighbor x.x.1.22 route-map s2_lan_out out
  neighbor x.x.0.5 next-hop-self
  neighbor x.x.0.5 route-map s1_dmz_out out
  neighbor x.x.1.5 next-hop-self
  neighbor x.x.1.5 route-map s2_dmz_out out
 exit-address-family


----------



## VladiBG (Apr 21, 2022)

OSPF Cost - OSPF Routing Protocol Metric Explained - Study CCNA
					

This post explains Open Shortest Path First (OSPF) Routing Protocol Metric Cost that can help you with your CCNA 200-301 study.




					study-ccna.com
				




Edit: For BGP check here https://docs.frrouting.org/en/latest/bgp.html

In my setup the ISP prepend the backup line so it's used only when the primary fail. (no multipath)


----------

