# Turning Raspberry Pi Wi-Fi Off If Connected Over Ethernet Note that if you followed [[Turn On Raspberry Pi Hotspot If Not Online]], following these steps is not necessary. Add the following to `/etc/rc.local`: ```shell #Check if eth0 is connected, if so disable WiFi /home/pi/bin/check_eth & ``` Add the actual `check_eth` script to (`/home/pi/bin/check_eth`) : ```shell #!/bin/bash #This script checks if eth0 can connect, if so disable WiFi #Let system get up first, wait 30s sleep 20 EthAddr=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) WiFiAddr=$(ip addr show wlan0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) if [ -z $EthAddr ]; then echo "IP addr of eth0 not found, so use WiFi" echo "wlan0 IP=$WiFiAddr" else echo "Using Ethernet! Switch off WiFi." echo "eth0 IP=$EthAddr" echo "wlan0 IP=$WiFiAddr" cmd="ifconfig wlan0 down" $cmd fi ```