From charlesreid1

This page covers methods of connecting to wifi from Linux.

The methods break down as follows:

  • Use /etc/network/interfaces
  • Use wpa supplicant
  • How to connect to encrypted vs. unencrypted wifi

Use etc network interfaces

NOTE: This method is working on Raspberry Pi platform as of April 2017.

Main Page: Linux/Wireless/2


To set the wireless network you want a Linux box to join, you can add the network name and passphrase to /etc/network/interfaces. Better yet, you can create one file for each network you want to have ready to go, and swap them in and out by sourcing them or not from the /etc/network/interfaces file.

First, put the wifi configuration information into a file. This will be called mynetwork.cfg, and will be stored in /etc/network/interfaces.d/mynetwork.cfg.

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid NetName
wpa-psk NetPassword

The next step is to reference this configuration file from the /etc/network/interfaces file. Here is what that file looks like:

source /etc/network/interfaces.d/mynetwork.cfg

The /etc/network/interfaces.d/ folder would contain credentials for several networks, and could be swapped out by editing /etc/network/interfaces.

WPA Supplicant Method