wpa_supplicant

Goal: Allow to connect to a wireless network with Linux CLI

Stop NetworkManager service when using wpa_supplicant!

Connect to WPA Enterprise

Example of a wpa_supplicant configuration file for WPA Enterprise

1. Create a configuration file

radius.conf
network={
scan_ssid=1
eap=PEAP
bssid=FC:EC:DA:4F:9A:E9  #to change (not a mandatory)
ssid="MonPrecieux"       #to change
key_mgmt=WPA-EAP
identity="agagnonhebert" #to change
password="password123"   #to change
phase1="peaplabel=0"
phase2="auth=MSCHAPV2"
}

Single quote ' in the config file won't be parse correctly

2. Connect to the wireless interface

wpa_supplicant -c <path_to_radius.conf> -i <interface>
#Example
wpa_supplicant -c /home/aghebert/radius.conf -i wlan1

3. Ask for an IP address for the interface connected to WPA Enterprise network

dhclient -v -i <interface>
#Example
dhclient -v -i wlan1

The image below shows that the wlan1 interface now has the IP 172.18.0.181. The IP address of the WiFi router is 172.18.0.1.

4. Make sure that the gateway is propely set using route

Connect to WPA/WPA2-PSK

Follow the same steps than for WPA-Enterprise, but use the following config file:

wpa_supplicant.conf
network={
 ssid="XYCompany"
 scan_ssid=1
 key_mgmt=WPA-PSK
 psk="raspberry@1"
}
wpa_supplicant -Dnl80211 -i wlan1 -c wpa_supplicant.conf

We can now request an IP address with dhclient as shown in the section above.

Last updated