First, examine network interfaces. On Raspberry Pi 3 Model B, it should have three.
$ ls /sys/class/neteth0 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.
You should see wlan0 has an IP address assigned.ip a
No comments:
Post a Comment