# lagg and /etc/rc.conf



## waasnsteffl (Jan 20, 2022)

Hi.
First thanks for all the work with forums.freebsd.org

My question -
Is there a way or consistent trick to get those TWO lines for lagg failover configuration started in rc.conf, without  writing a rc.d script.

ifconfig lagg0 laggproto lacp laggport em0 laggport wlan0 
and
ifconfig lagg0 laggproto failover laggport em0 laggport wlan0


Thanks in advance, Anton


----------



## zirias@ (Jan 20, 2022)

Uhm, I'm pretty sure they are mutually exclusive. LACP is used to negotiate trunking of both interfaces with a switch, so you most likely don't need/want it.


----------



## SirDice (Jan 20, 2022)

Yeah, you use LACP _or_ failover, not both. That said, this will do the trick:

```
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport em0 laggport wlan0"
```


----------



## waasnsteffl (Jan 20, 2022)

cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport em0 laggport wlan0"

Yes, I had this as very first test, but no clean switching between  both interfaces..

Now just tested it with only first line then the other, after deleting and recreating wlan0, em0, then lagg0. then dhclient on lagg0.
Using only both lines in a script worked with clean dhcp and fast switching, putting one interface and then the other or both down, up etc.

I use standard tp-link accesspoint, but em0 cannected to a devolo ethernet over powerline. both on a switch which is connected to raspi firewall with FreeBSD ( what else ).   

If said, that only one line lagg with failover command should be enough, could the devolo be the problem?

looks like i have to use a rc.d script

And again thanks for fast responsion, Anton


----------



## SirDice (Jan 20, 2022)

Check the LACP status on the switch too, both ports need to be configured for LACP on there too. So this is likely not going to work with LACP being split over wireless and wired. You can typically only enable LACP on two or more ports, on the same switch. In your case there's a wireless AP in between on one of the connections.


----------



## zirias@ (Jan 20, 2022)

I'm pretty sure with "no clean switching", OP actually meant failover behavior (using one OR the other interface) and should understand LACP is something completely different, used to trunk all interfaces together (all active).


----------



## SirDice (Jan 20, 2022)

Failover is likely not going to be "seemless" though. Suppose the laptop is connect with ethernet to port 1 of the switch, the AP is on port 2. The switch will see a source MAC address on port 1 and will switch any packets with that MAC address as destination to port 1 (CAM tables of the switch). When you failover that MAC would suddenly be connected to port 2 via the AP. The switch however will 'remember' it being connected to port 1 and will continue to send that traffic to port 1. Either the MAC address needs to timeout in the CAM table or the switch needs to 'relearn' that MAC address is now connected to port 2.


----------



## waasnsteffl (Jan 20, 2022)

@Zirias​Yes i "meant failover behavior", wrong way to use lagg for this intention? better idea ?
but seems to work pretty clean and fast.
intention is to switch automatically to significantly faster ethernet, when a cable is near and available (at home) and does not hang around


----------



## zirias@ (Jan 20, 2022)

lagg can do failover, that's what the failover mode is for.

The lacp mode is NOT for failover but for trunking multiple links together using the LACP (link aggregation control protocol), requiring the other end (typically a switch) to support that protocol as well.


----------

