[Raspberry Pi] Configure Ubuntu Server Wi-Fi from CUI Commands

Linux

Overview

This is a note from installing Ubuntu Server on a Raspberry Pi, connecting a display and keyboard, and configuring Wi-Fi. With the Desktop edition, you can configure it from the GUI, so you probably do not need to do it from commands.

If you want to install and configure it without connecting a display or keyboard, see "[Raspberry Pi 4] Headless Install of Ubuntu Server 21.04 (No Monitor or Keyboard) Beginner-Friendly".

Test Environment

Raspberry Pi 4 8GB
Ubuntu Server (Ubuntu 21.04)

Configuration

Add the Wi-Fi settings to /etc/netplan/50-cloud-init.yaml.
Write the SSID and password of the Wi-Fi you want to connect to in the [SSID] and [PASSWD] parts. The square brackets [ ] are not needed.

$ sudo /etc/netplan/50-cloud-init.yaml
nework:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            dhcp4: true
            optional: true
            access-points:
                [SSID]:
                    password: "[PASSWD]"

After configuring it, apply the settings with the netplan command.
You can check the connection status with the wifi-status command.

$ sudo netplan apply
$ wifi-status
Every 1.0s: iw wlan0 info; ip addr show wlan0; ip route; echo; (journalctl -b --no-pager -q | grep -i wlan0 | tail -n 10 | sort -r); ech...  ubuntu: Mon Sep 13 08:58:27 2021

Interface wlan0 ifindex 3 wdev 0x1 addr dc:a6:32:e1:c7:74 ssid hagenet type managed wiphy 0 channel 44 (5220 MHz), width: 80 MHz, center1: 5210 MHz txpower 31.00 dBm 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether dc:a6:32:e1:c7:74 brd ff:ff:ff:ff:ff:ff inet 192.168.11.130/24 brd 192.168.11.255 scope global dynamic wlan0 valid_lft 6294sec preferred_lft 6294sec inet6 fe80::dea6:32ff:fee1:c774/64 scope link valid_lft forever preferred_lft forever default via 192.168.11.1 dev wlan0 proto dhcp src 192.168.11.130 metric 600 192.168.11.0/24 dev wlan0 proto kernel scope link src 192.168.11.130 192.168.11.1 dev wlan0 proto dhcp scope link src 192.168.11.130 metric 600

When I put the Raspberry Pi in a metal (aluminum) case, Wi-Fi sensitivity dropped, but after I started using TP-Link mesh Wi-Fi, the Raspberry Pi Wi-Fi has been stable too.

Me
Me

For now, I like Physical Computing Lab's aluminum case.

Sponsored links
Follow ☆Geha☆