Ubuntu Lunar wifi client: Difference between revisions

From embeddedTS Manuals
(Created page with " If connecting to a WPA/WPA2 network, a wpa_supplicant config file must first be created: <source lang=bash> wpa_passphrase yournetwork yournetworkpassphrase > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf </source> Create the file /lib/systemd/system/wpa_supplicant@.service with these contents <source lang=bash> [Unit] Description=WPA supplicant daemon (interface-specific version) Requires=sys-subsystem-net-devices-%i.device After=sys-subsystem-net-devices-%i.device...")
 
No edit summary
 
Line 1: Line 1:
Wireless configuration under Ubuntu, similar to Ethernet, also uses netplan for configuration.  For example, create /etc/netplan/wifi.yaml:
<pre>
network:
  version: 2
  renderer: networkd
  wifis:
    wlan0:
      dhcp4: yes
      dhcp6: yes
      access-points:
        "yourssid":
          password: yourpassphrase"
</pre>


If connecting to a WPA/WPA2 network, a wpa_supplicant config file must first be created:
After creating the yaml file, set the appropriate permissions and apply the netplan:
<source lang=bash>
wpa_passphrase yournetwork yournetworkpassphrase > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
</source>
 
 
Create the file /lib/systemd/system/wpa_supplicant@.service with these contents
<source lang=bash>
[Unit]
Description=WPA supplicant daemon (interface-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
 
[Service]
Type=simple
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
 
[Install]
Alias=multi-user.target.wants/wpa_supplicant@%i.service
</source>
 
Next, enable the service to start up on boot:
<source lang=bash>
systemctl enable wpa_supplicant@wlan0
</source>
 
Create the file /etc/systemd/network/wlan0.network with:
<source lang=bash>
[Match]
Name=wlan0
 
[Network]
DHCP=yes
</source>
 
Enable networkd to run dhcp on startup:
<source lang=bash>
systemctl enable systemd-networkd
</source>


See the [[#Debian_Networking|systemctl-networkd]] example for setting a static IP for a network interface.  The wlan0.network can be configured the same way as an eth.network.  To enable all of the changes that have been made, run the following commands:
<source lang=bash>
<source lang=bash>
systemctl enable wpa_supplicant@wlan0
sudo chmod 600 /etc/netplan/*.yaml
systemctl start wpa_supplicant@wlan0
sudo netplan apply
systemctl restart systemd-networkd
</source>
</source>

Latest revision as of 12:04, 22 September 2023

Wireless configuration under Ubuntu, similar to Ethernet, also uses netplan for configuration. For example, create /etc/netplan/wifi.yaml:

network:
  version: 2
  renderer: networkd
  wifis:
    wlan0:
      dhcp4: yes
      dhcp6: yes
      access-points:
        "yourssid":
          password: yourpassphrase"

After creating the yaml file, set the appropriate permissions and apply the netplan:

sudo chmod 600 /etc/netplan/*.yaml
sudo netplan apply