197

Got a Pi 3 which will always use ethernet, so trying to figure out how to disable the WiFi such that it does not even turn on after a reboot.

If I do an ifconfig I see the wlan0 device. I can do ifconfig wlan0 down but it will come back up again after a reboot.

I tried commenting out anything about wlan0 (and wlan1) in /etc/network/interfaces but that has not made a difference.

eth0 is not commented out so it can be used.

SDsolar
  • 2,378
  • 8
  • 26
  • 43
Evan
  • 2,072
  • 2
  • 12
  • 8

11 Answers11

335

To completely disable the onboard WiFi from the firmware on the Pi3 / Pi4, add

dtoverlay=disable-wifi

in /boot/config.txt.

This is documented here. Please be sure to use an up to date firmware, this feature was added in January 2017.

There is also an overlay for disabling onboard bluetooth : disable-bt. If you want to disable both wifi and bluetooth, you need to add these 2 lines :

dtoverlay=disable-wifi
dtoverlay=disable-bt

NOTE : If you are using an old 'Pi3 only' firmware, you need to prefix the overlay name with pi3-. See this issue

Ludovic Ronsin
  • 3,466
  • 2
  • 11
  • 5
50

See Ludovic Ronsin's answer above about using dtoverlay, a method added in January 2017.

This post seems to be talking about this. The answer talks about disabling the drivers by editing the file /etc/modprobe.d/raspi-blacklist.conf and adding:

blacklist brcmfmac
blacklist brcmutil

Alternatively, you could use crontab -e and add:

@reboot sudo ifdown wlan0

So that command runs at each boot.

Hope this helps, I'm still waiting for my Pi 3 to arrive.

Seamus
  • 23,558
  • 5
  • 42
  • 83
Patrick Cook
  • 6,365
  • 8
  • 38
  • 63
34

You can use

sudo iwconfig wlan0 txpower off

This should disable the wifi adapter.

Use sudo iwconfig wlan0 txpower on to enable it again.

Reference: https://manpages.debian.org/buster/wireless-tools/iwconfig.8.en.html

clel
  • 103
  • 2
yavuzaksan
  • 441
  • 4
  • 2
11

We have measured the RF from the Pi 3 (when used as a WiFi hotspot) and confirmed that this statement disables the Pi's WiDi transmitter when used as a hot spot:

sudo ifconfig wlan0 down

You can also easily create a clickable button on the taskbar to do this. Instructions are found here: http://orbisvitae.com/ubbthreads/ubbthreads.php?ubb=showflat&Number=81166#Post81166

Russ
  • 121
  • 1
  • 3
9

I modified the rc.local using command sudo nano /etc/rc.local, and added ifconfig wlan0 down in it. However, if Ethernet is not connected or IP is not assigned to wired interface then the WiFi is on. This gives a backup way to connect the RasPi when running headless.

Install ethtool with sudo apt-get install ethtool.

Then copy the script below to sudo nano /etc/rc.local right before exit 0, so the last lines look like this:

# Disable WiFi if wired.
logger "Checking Network interfaces..."
if ethtool eth0 | egrep "Link.*yes" && ifconfig eth0 | grep "inet"; then
  logger 'Disabling WiFi...'
  ifconfig wlan0 down
else
  logger 'WiFi is still enabled: Ethernet is down or ethtool is not installed.'
fi

exit 0

Then save using CTRL + X and reboot. It seems to work for me, as after reboot ifconfig does not give wlan0.

7

You can also use the rfkill command to disable or enable the Wi-Fi interface(s). This is how the interface is disabled by Raspberry Pi OS (Raspbian) with a new installation before the country has been configured in the Wi-Fi settings (e.g using raspi-config). You can disable the Wi-Fi interface(s):

sudo rfkill block wifi

Enable it like this:

sudo rfkill unblock wifi

And check the current state of the interfaces:

rfkill list

If you want enable/disable specific interfaces use the index shown by rfkill list to the un/block command. For example, you can usually just block the built-in WiFi interface like this (if this doesn't always control the correct interface see this question for more details):

rfkill block wifi 0

The rfkill state will be maintained across reboots as it is reinstated on bootup by the systemd-rfkill service.

Pierz
  • 852
  • 11
  • 9
5

Apart from blacklisting which has the risk of a lockout in case you need to reboot and no ethernet is available, you can also unload the kernel module as follows:

sudo modprobe -r -v brcmfmac

But I'm not sure unloading the device drivers is a good idea as I fear the wlan0 device may still draw power and even more so if the device drivers' power management features are not loaded, currently I keep drivers loaded and simply make sure the default route via wlan0 is disabled:

sudo ip route del default via <Gateway IP> dev wlan0

This will make sure all traffic will go via eth0 and (hopefully) be more stable and so forth for example for the ntp daemon.

Patrick B.
  • 312
  • 1
  • 8
  • 23
3

I use the following command wpa_cli terminate, I have that command in my /etc/rc.local

MadAntrax
  • 941
  • 7
  • 8
3

I'm using my pi as an access point (wifi hotspot). This works for me:

# Turn off
sudo service hostapd stop && sudo service isc-dhcp-server stop && sudo ifconfig wlan0 down && sudo service isc-dhcp-server start

And to turn it back on without restarting the pi, run this:

# Turn on
sudo service isc-dhcp-server stop && sudo ifconfig wlan0 up && sudo service hostapd start && sudo service isc-dhcp-server start
nmrugg
  • 131
  • 3
2

Other solution is to edit /etc/network/interfaces file, comment/remove lines about Wi-Fi connection (wlan0) and add line:

iface wlan0 inet manual
pbies
  • 298
  • 5
  • 14
-4

The easiest way to disconnect from a Wifi network on Pi 3 is to enter some useless password! Click on your Wifi network, it will again ask for password but this time enter random text and you will be disconnected.