Page 1 of 1

Turn-off Wifi when connected to LAN - PiZero

Posted: Thu Aug 30, 2018 2:28 pm
by PA2TSL
Hello all,

I have a LAN to USB adapter in use with my PiZero - Jumbospot hotspot.
This works fine, and it is much more stable compared with the Wifi option.
This is, to my opinion, the best solution when the hotspot is on a fixed location.
However, it appears that the Wifi is not turned off when the LAN option is used...
So now I have 2 different IP addresses... which is not a disaster but I want to use only the LAN IP address when it is connected to it..
Is it possible to get the Wifi turned-off when the LAN port is used?? And, of course, will the Wifi be available again as soon as the LAN is disconnected?

Re: Turn-off Wifi when connected to LAN - PiZero

Posted: Thu Aug 30, 2018 6:57 pm
by M0GLJ
You could write a script that looks for an ethernet connection and then disables wifi and then when if can't see the ethernet enables wifi

Re: Turn-off Wifi when connected to LAN - PiZero

Posted: Sat Sep 01, 2018 9:08 am
by PA2TSL
Maybe this could be an 'enhancement' in the Pi-Star image. Unfortunately, I do not have the expertise to create that script.

Re: Turn-off Wifi when connected to LAN - PiZero

Posted: Fri Apr 05, 2019 12:17 pm
by PA2TSL
CAUTION: I have found a serious problem when using the command rfkill, see my edit in the original post:

I have (I thought I had), finally, found a simple work-around to disable wifi when connected to LAN.
You have to use SSH access in the Expert mode, and typing the following command:

sudo rfkill block wifi

That's all! To enable wifi again just reboot (THIS DOES NOT WORK, WiFi REMAINS OFF AFTER A REBOOT/RESTART!!!), or use the following command:

sudo rfkill unblock wifi (this only works with the LAN connected!)

You can view the interface status in the Wireless Configuration screen.
Btw, the cmd 'rfkill' is only available in the beta version 4 of Pi-Star...

So, finally, this option to turn the wifi adapter temporary off is not useful: it corrupts something so that the wifi adapter will not turn on after rebooting or restarting... Still searching for a proper solution...

This situation is also applicable for the Raspberry Pi 3B (+) which has LAN and wifi.