Difference between revisions of "Connecting to WiFi network using systemd and wpa-supplicant"
From SomLabs Wiki
(Created page with "{{PageHeader|Connecting to WiFi network on VisionSOM-STM32MP1}} In order to connect to the WiFi network a proper configuration needs to be provided. This tutorial shows how t...") |
|||
Line 1: | Line 1: | ||
{{PageHeader|Connecting to WiFi network on VisionSOM-STM32MP1}} | {{PageHeader|Connecting to WiFi network on VisionSOM-STM32MP1}} | ||
− | In order to connect to the WiFi network a proper configuration needs to be provided. This tutorial shows how to do this using the wpa_supplicant tool. | + | In order to connect to the WiFi network a proper configuration needs to be provided. This tutorial shows how to do this using the ''wpa_supplicant'' tool and the ''systemd'' service manager. |
− | First, | + | First, create the ''/etc/wpa_supplicant'' directory and the ''/etc/wpa_supplicant/wpa_supplicant-wlan0.conf'' file with the following configuration: |
<pre> | <pre> | ||
Line 22: | Line 22: | ||
The network in the example is protected with the WPA2 standard and requires a password. The <NETWORK_SSID> and <NETWORK_PASSWORD> fields need to be changed according to the existing network configuration. | The network in the example is protected with the WPA2 standard and requires a password. The <NETWORK_SSID> and <NETWORK_PASSWORD> fields need to be changed according to the existing network configuration. | ||
− | Create the ''/etc/network/ | + | Create the ''/etc/systemd/network/wlan.network'' file: |
<pre> | <pre> | ||
− | + | [Match] | |
− | + | Name=wlan0 | |
− | + | ||
− | + | [Network] | |
− | + | DHCP=ipv4 | |
− | + | </pre> | |
+ | |||
+ | Enable the ''wpa_service'' for the ''wlan0'' interface: | ||
+ | |||
+ | <pre> | ||
+ | systemctl enable wpa_supplicant@wlan0.service | ||
</pre> | </pre> | ||
− | + | Restart the ''systemd-networkd'' and ''wpa_supplicant'' services: | |
<pre> | <pre> | ||
− | + | systemctl restart systemd-networkd.service | |
+ | systemctl restart wpa_supplicant@wlan0.service | ||
</pre> | </pre> | ||
Line 45: | Line 51: | ||
</pre> | </pre> | ||
− | The wireless network (wlan0) should now be enabled and configured: | + | The wireless network (wlan0) should now be enabled and configured after each system boot: |
<pre> | <pre> |
Revision as of 18:50, 2 June 2020
Connecting to WiFi network on VisionSOM-STM32MP1
In order to connect to the WiFi network a proper configuration needs to be provided. This tutorial shows how to do this using the wpa_supplicant tool and the systemd service manager.
First, create the /etc/wpa_supplicant directory and the /etc/wpa_supplicant/wpa_supplicant-wlan0.conf file with the following configuration:
ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 update_config=1 network={ ssid="<NETWORK_SSID>" psk="<NETWORK_PASSWORD>" key_mgmt=WPA-PSK proto=WPA2 pairwise=CCMP TKIP group=CCMP TKIP scan_ssid=1 }
The network in the example is protected with the WPA2 standard and requires a password. The <NETWORK_SSID> and <NETWORK_PASSWORD> fields need to be changed according to the existing network configuration.
Create the /etc/systemd/network/wlan.network file:
[Match] Name=wlan0 [Network] DHCP=ipv4
Enable the wpa_service for the wlan0 interface:
systemctl enable wpa_supplicant@wlan0.service
Restart the systemd-networkd and wpa_supplicant services:
systemctl restart systemd-networkd.service systemctl restart wpa_supplicant@wlan0.service
and check the interface status:
ip a
The wireless network (wlan0) should now be enabled and configured after each system boot:
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether a0:cc:2b:2c:6b:8d brd ff:ff:ff:ff:ff:ff inet 192.168.43.234/24 brd 192.168.43.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 2a00:f41:581c:fc61:a2cc:2bff:fe2c:6b8d/64 scope global dynamic mngtmpaddr valid_lft 3574sec preferred_lft 3574sec inet6 fe80::a2cc:2bff:fe2c:6b8d/64 scope link valid_lft forever preferred_lft forever