Wpa Supplicant Configuration

How to configure Wpa Supplicant

wpa

Setting up WpaSupplicant in debian 11

Install Wpa Supplicant
1
sudo apt install wpasupplicant

Generate the password :

Generate the config file
1
2
3
4
5
6
7
$ wpa_passphrase MYSSID passphrase

network={
    ssid="MYSSID"
    #psk="passphrase"
    psk=59e0d07fa4c7741797a4e394f38a5c321e3bed51d54ad5fcbd3f84bc7415d73d
}

After that, copy wpa_supplicant.conf file to /etc/wpa_supplicant/ :

Modifying accordly your needs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
network={
   proto=RSN
   key_mgmt=WPA-PSK
   pairwise=CCMP TKIP
   ssid="SSID"
   priority=5
   bssid=6c:72:20:3d:c8:96
   #psk="pass"
   psk=aae3619e4a3865d7ae6b9897cde7e5ede3efdbad86be8d8b3ae5c016a1d685e6
}

Add a interface block config and edit /etc/network/interfaces file:

dhcp to interface
1
2
3
4
5
6
7
8
#
# Autostart Wifi Source
#
allow-hotplug wlp3s0
auto wlp3s0
iface wlp3s0 inet dhcp

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Automatic Startup

Using systemd for autoboot

The wpa_supplicant package provides multiple systemd service files:

Run as a Service

wpa_supplicant.service

uses D-Bus, recommended for NetworkManager users.

wpa_supplicant@interface.service

accepts the interface name as an argument and starts the wpa_supplicant daemon for this interface. It reads a /etc/wpa_supplicant/wpa_supplicant-interface.conf configuration file. Useful when using systemd-networkd.

wpa_supplicant-nl80211@interface.service

also interface specific, but explicitly forces the nl80211 driver (see below). The configuration file path is /etc/wpa_supplicant/wpa_supplicant-nl80211-interface.conf .

wpa_supplicant-wired@interface.service

also interface specific, uses the wired driver. The configuration file path is /etc/wpa_supplicant/wpa_supplicant-wired-interface.conf .

Note

To enable wireless at boot, enable an instance of one of the above services on a particular wireless interface. For example, enable the wpa_supplicant@interface systemd unit. Now choose and enable an instance of a service to obtain an ip address for the particular interface. For example, enable the dhcpcd@interface systemd unit.

Set Static Interface Configuration

We can set the wlan interface to static ip in /etc/network/interfaces configuration file:

Add static ip parameters
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#
# Autostart Wifi Source
#
allow-hotplug wlp3s0
auto wlp3s0
iface wlp3s0 inet static
  address 192.168.1.153
  netmask 255.255.255.0
  gateway 192.168.1.254
dns-search invalid
dns-nameservers 1.1.1.1 8.8.8.8
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Add to systemd :

Start at boot
1
sudo systemctl enable wpa_supplicant@wlp3s0.service

Last update: Nov 20, 2024