Disable the WiFi Interface on the Raspberry Pi

The Raspberry Pi 3 has an integrated WiFi interface, what to do if you want to use the Ethernet cable instead and prevent the WiFi interface to auto-configure? There are several recipes on the internet, many of them are outdated and not optimal for a modern Raspbian based on Debian 9.4 Stretch.

Today the network subsystem is handled by dhcpcd5 packages, you should not fiddle anymore with the /etc/network/interfaces file. A simple solution to deny the WiFi interface configuration is shown in the example below. An alternative is to prevent just the configuring of the default gateway, so you can enable both Ethernet and WiFi, but use the Ethernet for internet access. The alternative is shown as commented lines.

Add the following to the /etc/dhcpcd.conf file:

# We use the Ethernet: do not configure the WiFi interface.
denyinterfaces wlan0
# Alternatively: does not install a default gateway.
#interface wlan0
#nogateway