wpa_supplicant
Establishing an automatic wifi connection through wpa_supplicant
This is a small step by step guide how to set up wifi and have it run and managed by systemd on every boot.
1) install wpa_supplicant & dialog (if you want to use wifi-menu for testing purposes)
Then create a default wpa_supplicant.conf in /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/run/wpa_supplicant
update_config=1
Find out interface name
ip a
If you are not sure, you can use some ncurses tool like wifi-menu to set up your connection first (it also uses wpa_supplicant) and then come back to set up wpa_supplicant manually.
Scan for networks
[yabbes@x220 ~]$ wpa_cli
wpa_cli v2.6
Selected interface 'wlp3s0'
Interactive mode
> scan
OK
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-RESULTS
# print the results
> scan_results
OK
# take note of your SSID and add it as network 0
> add_network 0
0
> set_network 0 ssid "SSID"
OK
> set_network 0 psk "passphrase"
OK
> enable_network 0
OK
> save_config
OK
now exit wpa_cli and take note that your settings have been saved in /etc/wpa_supplicant/wpa_supplicant.conf
[root@x220 yabbes]# cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/run/wpa_supplicant
update_config=1
network={
ssid="SSID"
psk="passphrase"
}
If we want to enable this unit through systemd it expects a naming convention like wpa_supplicant-<interface>.conf
so let’s proceed
mv wpa_supplicant.conf wpa_supplicant-<interface>.conf
# enable and start the systemd service
systemctl enable wpa_supplicant@<interface>.service
systemctl start wpa_supplicant@<interface>.service
# now to acquire an ip address via dhcpcd
dhcpcd <interface>
# and to do so on every boot we register it as a service
systemctl enable dhcpcd@<interface>
That’s it, it should have worked for you and you can finally ping 8.8.8.8