Posted in: DMR, HOW TO

DMR: Pi-Star disable wifi if connected via ethernet

This procedure is located in the pi-star forum. I added all the linux commands to do it so that a linux noobie would be able to install it.

In Pi-Star if you have both wifi on and are connected via an ethernet cable here is a procedure to use to disable the wifi automatically. If you are only connected via wifi this procedure will not disable the wifi.

Go to configuration then expert then SSH and log in

first you need to install ethtool using the following command

.sudo apt install ethtool

then issue the following commands

rpi-rw

cd /etc

sudo chmod 777 rc.local

nano rc.local

then place the following lines before the end of the file in /etc/rc.local

(the last line of the file must be exit 0)

# Disable WiFi if wired connection.
logger “Checking Network interfaces…”
if sudo ethtool eth0 | egrep “Link.*yes” && ifconfig eth0 | grep “inet”; then
logger ‘Disabling WiFi…’
sudo ifconfig wlan0 down
else
logger ‘WiFi is still enabled: Ethernet is down.’
fi

issue a ctl o to write the file

issue a ctl x to exit nano

issue a sudo chmod 755 rc.local to restore the permissions

issue a rpi-ro to reset the file system to read only

you are now done.

Issue an exit to leave SSH

 

I took the procedure from the pi-star forum and added to it all the commands needed to actually implement it.

I did it to my system and it works fine.

By Al AF4FA