So, you flashed Ubuntu onto your SD card and booted Raspberry Pi for the first time, But realized that it’s not connected to the internet. Or maybe you just want to move from a wired Ethernet connection to WiFi. Well in this article we will discuss how to connect to WiFi using Ubuntu’s Netplan utility which is easy comparative to the wpa_supplicant utility which we used earlier..
Follow the steps below to Configure Wifi on Ubuntu
1. Update system (Optional):
sudo apt update
sudo apt full-upgrade
sudo reboot
2. Determine interface names (copy wireless interface)
ip link show
# 1: lo: <LOOPBACK,UP,LOWER_UP> …
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> … state UP …
# 3: wlan0: <BROADCAST,MULTICAST> … state DOWN
3. Determine your-cloud-init.yaml and open for editing (prefix 50 most of the times)
cd /etc/netplan/
ls -l
# -rw-r--r-- 1 root root 666 May 15 22:00 50-cloud-init.yaml
### note your *-cloud-init.yaml file name
### backup *-cloud-init.yaml file
cp 50-cloud-init.yaml 50-cloud-init.yaml.bak
### edit *-cloud-init.yaml
sudo nano 50-cloud-init.yaml
4. Add WiFi access information to *-cloud-init.yaml file
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# 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:
version: 2
ethernets:
eth0:
optional: true
dhcp4: true
# add wifi setup information here ...
wifis:
wlan0:
optional: true
access-points:
"SamTeck":
password: "iot.samteck.net"
dhcp4: true
Test, generate and apply the changed your-cloud-init.yaml config:
- Testing:
sudo netplan --debug try
(continue even if there are errors) - Generate:
sudo netplan --debug generate
(provides more details in case of issues with the previous command) - Apply:
sudo netplan --debug apply
(if no issues during the previous commands)
Confirmation Test:
sudo reboot
### wait, then without the wired ethernet connected ...
ssh ubuntu@wifi-ip-address
This is way easier compared to the old wpa_supplicant method in which we need to install it separately and much more steps for configuration.