Sunday, November 29, 2020

How to configure WiFi for Ubuntu Server 20.10 on Raspberry Pi 3

First, examine network interfaces. On Raspberry Pi 3 Model B, it should have three.  

$ ls /sys/class/net

eth0  lo  wlan0

The interface eth0 is for Ethernet connection, and wlan0 is for WiFi.

The configuration of WiFi access points is in /etc/netplan/50-cloud-init.yaml. The default configuration is as below.

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        eth0:
            dhcp4: true
            match:
                driver: bcmgenet smsc95xx lan78xx
            optional: true
            set-name: eth0
    version: 2

Append the following configurations to the file.

    wifis:
        wlan0:
            optional: true
            access-points:
                "MY_AP_NAME":
                    password: "MY_WIFI_PASSWORD"
            dhcp4: true

Where you need to replace MY_AP_NAME and MY_WIFI_PASSWORD. After modifying the configurations, use the command to apply the changes.

sudo netplan apply

Be careful about letter case of the access point name. To check if Raspberry Pi successfully connects to the WiFi, use the command line to list IP address for each network interface.

ip a
You should see wlan0 has an IP address assigned.

No comments:

Post a Comment

How to make external drives spin down automatically on Ubuntu 20.10

 The following steps have been tested on Raspberry Pi 3. When using Raspberry Pi as a file server, it would save energy and extend an extern...