Linux/Wireless
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
Joining Wireless Networks
Using /etc/network/interfaces
Joining network with WPA encryption
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.
Joining an open network
Repeat the above steps, but this time your wifi network's config file will look a little different for the open network:
auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-ssid LocalCoffeeShop
WPA Supplicant Method
NOTE: This is for WPA- and WPA2-encrypted networks only.
Main Page: Linux/Wireless/1
This method uses wpa_supplicant, and has been tested and works on a Rasbperry Pi.
First add network configuration to /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Your SSID Here"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="YourPresharedKeyHere"
}
Then edit /etc/network/interfaces and modify the wireless device to set the interface, and the wpa supplicant configuration file. Here is an example for a network with dynamic DHCP. This is the /etc/network/interfaces file:
# ------- DHCP ------------ ###allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp