# [SOLVED] automatic failover between wired and wireless

## 82303

Hi,

I am a BSD user possibly all my life. But I have a looong track record with Gentoo as well (at least 15 years by now. I think my first posting must have been around 2004 though). Now, after some years of absence, I installed myself a Gentoo as a parallel OS again. Everything works by now except some automagic failover between wired and wireless connections. And I wanted to ask what a Gentoo user uses for such things nowadays. Back in the olden days I used ifplugd. But it is not developed anymore and the very brief description in the wiki is not working for me at all. I have searched around in the forums a bit but all entries regarding ifplugd are really old and involve a quite complicated setup. I cannot remember doing more than installing and starting ifplugd and telling it about my interfaces. Well, how do you guys accomplish automatic failover on a notebook these days (I hope the solution does NOT involve systemd)

Cheers,

StefanLast edited by 82303 on Mon Mar 26, 2018 9:10 am; edited 1 time in total

----------

## audiodef

I use NetworkManager/nm-applet. (No systemd.) The wired connection can simply be checkboxed to automatically connect to this network when it is available. Connect to wifi when you want it. If you don't use it or it's not available, it auto-connects to the wired NIC.

----------

## Ant P.

I use dhcpcd + wpa_supplicant. Default behaviour in dhcpcd is to give wired a lower route metric than wireless, and the kernel will do its job.

----------

## UberLord

dhcpcd supports both Linux and BSD. I'm the author of dhcpcd, so I have some bias ...... use dhcpcd  :Wink: 

Out of the box it will do what you want

wpa_supplicant may need some minor tweakage depending on if it needs to work on a hotplugged interface.

The only buy in is that you don't use net.* to configure networking in Gentoo.

https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD

dhcpcd has been shipping with NetBSD since NetBSD-5 so I'm guessing you use some other BSD?

----------

## 82303

dhcpcd works like a charm. That's what I was expecting. Thanks for the heads up. Back in the days we had ta use a mixture of conf.d/net, ifplugd, and dhcpcd which obviously does not work anymore and is not necessary anyway.

I never really used NetBSD. Sure I installed it and played with it but the daily driver on my notebook is FreeBSD and here I just use the dhclient that ships with the base system in combination with a link aggregation mode 1. Works well and makes mapping of vlans to gain access to certain networks way easier. I will build such a config in gentoo later . But for now dhcpcd is what I was looking for  :Smile: 

Cheers,

Stefan

----------

## UberLord

That's an interesting solution. I note that the man page for lagg(4) also deals with the MAC address issue of mixing wired and wireless like that.

The only downside is that it assumes both wired and wireless are on the same subnet, which isn't always the case.

----------

## 82303

Oh it works well enough, even with the Wifi in a different subnet. The only thing that doesn't work from time to time is the failover. But not having to reconfigure my bridges, vlans and such whenever I switch between lan and wlan (multiple times a day) is worth the while. Unfortunately my company introduced some new video conferencing software that has a linux client but which I did not get to work with FreeBSD yet. So I have to have a Linux on my Lenovo P50 (excelent Linux/FreeBSD machine btw) in case I have to share my screen. So I am using good old Gentoo for such cases  :Smile: 

Now that I know that dhcpcd does failover well I will play around with it in combination with lagg(4) - always liked dhcpcd better than dhclient anyway  :Wink: 

----------

## UberLord

 *mrmarbury wrote:*   

> Oh it works well enough, even with the Wifi in a different subnet.

 

So which interface would you run the DHCP client on and how would the default route look (assuming both subnets had a default router) when changing over?

FreeBSD (like NetBSD) is limited to one default route. Hence the need for something like dhcpcd to manage this for you.

----------

## 82303

going highly OT now ...

This is part of my FreeBSD network Config:

```

cloned_interfaces="lagg0"

ifconfig_em0="up"

ifconfig_iwm0="up"

wlans_iwm0="wlan0"

ifconfig_wlan0="WPA"

create_args_wlan0="wlanaddr <mac address of em0>"

ifconfig_lagg0="laggproto failover laggport em0 laggport wlan0 DHCP"

```

So dhcp is executed on lagg0 (the bonding interface)

ifconfig then looks like this for lagg0

```

lagg0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500

   ether <macc address of em0>

   inet 10.0.0.113 netmask 0xffffff00 broadcast 10.0.0.255 

   nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

   media: Ethernet autoselect

   status: active

   groups: lagg 

   laggproto failover lagghash l2,l3,l4

   laggport: em0 flags=1<MASTER>

   laggport: wlan0 flags=4<ACTIVE>

```

I will send you a PM with my mail address so we can chat further, if you like

----------

