How to setup of Raspberry Pi 3 B+ onboard WiFi for Ubuntu Server 18.04? In particular, with netplan
?
This is a clean install of the Ubuntu Server 18.04 image for Raspberry Pi 3. File: ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img.xz
.
The installed file /etc/network/interfaces
states that netplan
has replaced ifupdown
.
# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
/etc/netplan
has one file 50-cloud-init.yaml
# 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:
dhcp4: true
match:
macaddress: <MAC 'eth0' [IF1]>
set-name: eth0
Netplan.io provides some general Netplan configuration examples.
To configure netplan, save configuration files under
/etc/netplan/
with a.yaml
extension (e.g./etc/netplan/config.yaml
), then runsudo netplan apply
.
... yet, no guideance specific to a RaspberryPi. ...in particular, with respect to the existing /etc/netplan/50-cloud-init.yaml file on the RaspberryPi Ubuntu Server install.
What would be the netplan
template for the RaspberryPi? Can the existing /etc/cloud/cloud.cfg.d
be left enabled? What is lost if cloud.cfg.d
on the Raspberry Pi is disabled? ... (... and, wondering ... how much of this issue needs RaspPi knowledge vs. Ubuntu knowledge.)
Note: Since this question is at the intersection of Ubuntu & Raspberry Pi, a related question was also posted on AskUbuntu.
-
2I'm not in a position to test right now (as my only connection to my Pis is over SSH right now, so if it doesn't work i'll lose connection), but this page here might fill in some of the blanks you need for the netplan and setting your country for the Wifi. I'll give this a test tonight if you're not having any luck.Larnu– Larnu2019年05月15日 08:30:56 +00:00Commented May 15, 2019 at 8:30
-
@Larnu The "Raspberry Pi 3B/B+ Wireless Bridge using Ubuntu Server 18.04 ARM Image and Netplan" link you provide included the needed steps. The essential steps needed for this particular question are now summarized as an answer. So, success. :-) Thanks.marc-medley– marc-medley2019年05月15日 22:55:31 +00:00Commented May 15, 2019 at 22:55
-
1Glad to see you got there. Would have had a go today of no but I see there's no need. :)Larnu– Larnu2019年05月16日 06:56:42 +00:00Commented May 16, 2019 at 6:56
1 Answer 1
The steps below were found to provide a persistent WiFi setup using netplan
with Ubuntu Server 18.04 ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img.xz
image on a Raspberry Pi 3 B+.
Update system:
sudo apt update
sudo apt full-upgrade
sudo reboot
Determine interface names:
ip link show
# 1: lo: <LOOPBACK,UP,LOWER_UP> ...
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> ... state UP ...
# 3: wlan0: <BROADCAST,MULTICAST> ... state DOWN
Determine your-cloud-init.yaml and open for editing.
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
### restrict read access
sudo chmod 640 /etc/netplan/50-cloud-init.yaml
### edit *cloud-init.yaml
sudo nano 50-cloud-init.yaml
Add WiFi access information to your-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:
"YOUR-SSID-NAME":
password: "YOUR-NETWORK-PASSWORD"
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
The above sequence was distilled from the "Raspberry Pi 3B/B+ Wireless Bridge using Ubuntu Server 18.04 ARM Image and Netplan" gist link mentioned in the question comments by Larnu. The gist goes well beyond just enabling WiFi since its turns the Pi into a Bridge.
Some additional useful WiFi setup steps.
Set hostname.
sudo hostnamectl set-hostname my-server-name
sudo nano /etc/hosts
127.0.0.1 localhost
# add host name
127.0.0.1 my-server-name
sudo nano /etc/cloud/cloud.cfg
# Set preserve_hostname to true for persistance after reboot
preserve_hostname: true
Verify from local Raspberry Pi commandline.
hostnamectl
# Static hostname: my-server-name
# Icon name: computer
# Machine ID: ...
# Boot ID: ...
# Operating System: Ubuntu 18.04.2 LTS
# Kernel: Linux 4.15.0-1036-raspi2
# Architecture: arm64
Enable mDNS.
If desired, enable Multicast DNS by installing Avahi. Avahi supports the mDNS/DNS-SD/RFC 3927/Zeroconf/Bonjour specification.
sudo apt install avahi-daemon
Remotely check mDNS resolution from another computer.
ping my-server-name.local
ssh [email protected]
-
2This is awesome! All steps described work with the pi 4Brandon– Brandon2020年01月19日 15:21:50 +00:00Commented Jan 19, 2020 at 15:21
-
3Also works with Ubuntu 19.10.1 (I used this with ubuntu-19.10.1-preinstalled-server-armhf+raspi3.img.xz on a Pi 3).Peter Gloor– Peter Gloor2020年01月23日 13:01:31 +00:00Commented Jan 23, 2020 at 13:01
-
3This worked on the
ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
image, thanks!Chad– Chad2020年06月02日 12:35:24 +00:00Commented Jun 2, 2020 at 12:35 -
These steps worked at first but now I don't see the wifi connected anymore. I haven't touched the config at all. I am on RaspberryPi 4 with Ubuntu Server 20.4
Linux ubuntu 5.4.0-1015-raspi #15-Ubuntu SMP Fri Jul 10 05:34:24 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
. Any faced this issue? I have tried following the steps again and it doesn't solve the problem.piepi– piepi2020年07月28日 11:05:20 +00:00Commented Jul 28, 2020 at 11:05 -
1
sudo chmod 640 /etc/netplan/50-cloud-init.yaml
;-)ScotchAndSoda– ScotchAndSoda2021年01月01日 17:56:55 +00:00Commented Jan 1, 2021 at 17:56