WPA-supplicant

Niellune
2025-11-29 11:03:14 +02:00
parent 52ad176008
commit 6fb343385f
3 changed files with 110 additions and 0 deletions
+110
@@ -107,12 +107,122 @@ Review the changes and apply them
![Partitioning 5](pictures/rpi-partition5.png)
## First boot
Insert the SD card into the Raspberry Pi, connect the HDMI cable and keyboard, then apply power. If everything is correct, the rainbow screen will appear and the Pi will begin booting, followed by the setup process. Choose the keyboard layout and create a username and password. After a short time, a login prompt will appear. Enter the username and password you created to access the terminal.
## Mount partitions
# 3 WPA-Supplicant
To connect to the internet, we will use **wpa-supplicant**. It is lighter than NetworkManager and will also be used later for scripting.
First, set the Wi-Fi country in the Raspberry Pi configuration:
``` shell
sudo raspi-config
```
Navigate to **Localisation Options → WLAN Country**, select your country. Also enable SSH in **Interface Options → SSH**.
Next disable **NetworkManager** loading and stop it:
``` shell
sudo systemctl disable NetworkManager
sudo systemctl stop NetworkManager
```
Check whether the wireless interface is enabled:
``` shell
rfkill list
```
This shows the state of all radio devices. If the wireless adapter is marked as **Soft blocked: yes**, the system has disabled it in software, which prevents the Wi-Fi interface from being used.
![Network 1](pictures/rpi-network1.png)
If it is blocked unblock it with:
``` shell
rfkill unblock wlan
```
Identify the wireless interface so wpa-supplicant can target the correct device. List wireless interfaces and their status:
``` shell
iwconfig
```
> [!NOTE]
> In my case the wireless interface name is **wlan0**, you need to adjust following commands according to your wireless interface name
Next, create the wpa-supplicant configuration file. You need the Wi-Fi network name (SSID) and password. If either contains spaces, place them in quotes. Generate the configuration and write it to the appropriate file (note that file name includes the interface name). Replace **WifiSSID** and **WifiPassword** with your own values:
``` shell
wpa_passphrase WifiSSID WifiPassword | sudo tee /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
```
Next, edit created configuration file:
``` shell
sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
```
Add the following lines at the beginning of the file, replacing `US` with your country code as needed:
``` shell
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
country=US
```
> [!NOTE]
> In case of hidden network you need to add *scan_ssid=1* inside *network* section
![Network 2](pictures/rpi-network2.png)
- **ctrl_interface** - specifies the directory where wpa-supplicant creates its control interface for communication with other programs. The `GROUP=netdev` part sets permissions so users in the `netdev` group can manage the interface. This is needed so that other programs and users can interact with wpa-supplicant to manage Wi-Fi connections without requiring full root access.
- **country** -sets the Wi-Fi regulatory domain according to the country
To enable DHCP on wireless interface, create or edit the network configuration file:
``` shell
sudo nano /etc/systemd/network/25-wlan.network
```
Add the following content, replace *wlan0* with your interface name:
``` shell
[Match]
Name=wlan0
[Network]
DHCP=yes
# Optional DNS server
DNS=8.8.8.8
```
Next we need to restrict access to the configuration file so only root can read/write it. Enable and start the **wpa-supplicant** service for the wireless interface. Start the **systemd network manager** to handle DHCP and network configuration. Finally disable and stop the default wpa-supplicant service to avoid conflicts with the interface-specific service:
``` shell
sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
sudo systemctl enable wpa_supplicant@wlan0.service
sudo systemctl start wpa_supplicant@wlan0.service
sudo systemctl enable systemd-networkd.service
sudo systemctl start systemd-networkd
sudo systemctl disable wpa_supplicant.service
sudo systemctl stop wpa_supplicant.service
```
Bring up the wireless interface:
``` shell
sudo ip link set wlan0 up
```
Check the status of the wireless interface:
``` shell
sudo iwconfig
sudo ifconfig
```
If the wireless connection is working, update the system and then reboot:
``` shell
sudo apt update
sudo apt upgrade -y
sudo reboot
```
Now you can connect to your raspberry pi with ssh, replace 10.0.0.10 with ip of you raspberry from **ifconfig** command:
``` shell
ssh carplay@10.0.0.10
```
# 4 Optimise boot
# 5 Minimal desktop
BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB