What worked for me : Ubuntu : Stop wireless if LAN detected

Every now then I had to move my raspberry pi 3 between rooms. One of the room had router, therefore the Raspi3 was connected via LAN. The other, however was far away so wireless was required.

I had my DHCP set with mac binding. This assigned same IP to my devices and helped with shortcuts for Remote desktop, PuTTy etc. However because of this movement of Raspi3 between WLAN and ETH, I had to manually disable and enable the other network adapter.  Until I found below script.

Create script file as below

sudo nano /etc/NetworkManager/dispatcher.d/99-wlan

Copy below text.  Replace eth0 with whatever your eth interface is

#!/bin/bash
if [ "$1" = "eth0" ]; then
    case "$2" in
        up)
            nmcli radio wifi off
            ;;
        down)
            nmcli radio wifi on
            ;;
    esac
fi

Set permissions

chmod +x /etc/NetworkManager/dispatcher.d/99-wlan

Check Also

What worked for me : Windows 7 update Error

For long I kept on facing this peculiar issue where windows update would hang on while “Checking …

Why fingers wrinkle when wet

The old solution is that wrinkling is simply the result of your fingers and toes …

Leave a Reply

Your email address will not be published. Required fields are marked *