Solved Automatically switch from wifi to ethernet? Slow speed.

On my T470s at home, I typically use wifi but I plug into ethernet when possible.

But plugging into ethernet doesn't change the speed -- I'm still getting ~25Mbps wired or wireless.

Is there something I must do to manually switch to ethernet?

I've tried:
- rebooting while connected to ethernet
- testing other laptops (Linux and W10) on the same wire (they achieve almost 300Mpbs WAN as expected)
- testing LAN transfers which are also abysmal on this device

I ran ifconfig
Code:
em0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=81249b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LRO,WOL_MAGIC,VLAN_HWFILTER>
        ether 8c:16:45:0b:24:99
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

Did I fail to configure something correctly?
 
Well, it seems that while your ethernet interface is connected it doesn't have an IP. I don't know how it would be supposed to acquire one in relation to your setup but without an IP it's obviously not going to work.
 
You are going to need to take down your wifi connection either in /etc/rc.conf or manually.
ifconfig wlan0 down
service netif restart
service routing restart

Make sure you have your wired interface enabled in /etc/rc.conf
ifconfig_em0="DHCP"
 
Actually "ifconfig wlan0 down" in Phishfrys comment does not have any affect as long as you have wlan0 enabled in your /etc/rc.conf
once you issue "service netif restart" it will go up again
you will have ip on both interfaces wlan0 and em0 but all packages will be routed through em0
can it cause problems ? depends on what you are trying to do

if you want to completely disable wlan interface either:
1) you can issue "ifconfig wlan0 down" after you restart networking and routing
2) you can disable wlan0 in rc.conf and enable em0 only, restart networking / routing like Phishfry suggests

Also regarding to your ifconfig output it shows that your em0 is down when a interface is up you should see UP in flags section
 
You are going to need to take down your wifi connection either in /etc/rc.conf or manually.
ifconfig wlan0 down
service netif restart
service routing restart

Make sure you have your wired interface enabled in /etc/rc.conf
ifconfig_em0="DHCP"

Ok, so I had failed to add ifconfig_em0="DHCP", thank you for this suggestion.

The result now is that on a full reboot with ethernet plugged in, the eth port gets priority and I get expected speed.

BUT when I boot with no ethernet connected and then plug it in, I use the commands
ifconfig wlan0 down --> kills wifi
service netif restart --> restarts wifi
service routing restart

meaning I basically turn wifi off and back on again, rather than switching to eth.
 
Well, i am not very experienced with this yet but you should be able to automate this. Take a look at devd(8) and devd.conf(5) (specially the notify matching on IFNET / LINK_UP). These should allow you to configure your system in such a way that dhcpcd(8) / dhclient(8) is run on em0 as soon as a cable is detected (to acquire an IP).

Now you just need to make ethernet the preferred route. There should be 2 options to do this:
  1. Setup a more (or really 2) specific default route(s) for em0. Meaning instead of 1 route with target of 0.0.0.0 and netmask of 0.0.0.0 you set up one as 0.0.0.0 netmask 128.0.0.0 and a second as 128.0.0.0 netmask 128.0.0.0. Given those are more specific than the 0.0.0.0 netmask 0.0.0.0 that would be used on wlan0 they get preferred and the route over wlan0 practically ignored.
  2. Metric. You should be able to give one of your routes (em0) a lower metric thereby making it the preferred route. I've never tried that anywhere let alone on FreeBSD but i guess it's an universal thing and it seems easy enough.
 
There is a much easier way to do this, with one caveat--you have to be on the same layer 2 network via WiFi as you are with wired Ethernet (such that you can use the same IP address on both). If that's the case, you should configure a lagg(4) interface as is detailed in the handbook here (example 31.3).
 
you should configure a lagg(4) interface as is detailed in the handbook here (example 31.3).

Thank you `Orum, this guide was the solution.

To summarize for others finding this thread:

I had no success until I realized
Code:
iwm_load="YES"
iwm8265fw_load="YES"

were not in /boot/loader.conf. My wifi had been functional, so maybe there's a generic driver in base that made the modem work?

Once those were added, the code from lagg(4) was fine:
Code:
ifconfig_re0="ether b8:ee:65:5b:32:59"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA"
create_args_wlan0="country FR"
cloned_interfaces="lagg0"
ifconfig_lagg0="up laggproto failover laggport re0 laggport wlan0 DHCP"

changing only re0 for em0 and ath0 for iwm0. Now my laptop switches seemlessly to and from ethernet and wifi.

Thanks to everyone for your helpful suggestions.
 
Back
Top