Table of Contents list

Ubuntu Server uses Netplan to configure the network interfaces. This page contains a simple configuration file to get the Raspberry Pi connected to a WiFi network.
For the full documentation and more advanced configurations, I'll refer to the Netplan reference.

Configuring the WiFi if you already have access to the Pi's console

Follow this section if you already have access to the console of the Pi, either over SSH using the Ethernet connection, or using the serial port.

SSH over Ethernet

Connect to the Raspberry Pi over SSH, as explained on the Setting up Ubuntu page:

ssh RPi3

Terminal over the Serial Port

If you don't have access to an Ethernet connection, you can connect a 3.3V UART to USB or 3.3V UART to RS-232 adapter to the Pi's serial port (TX (GPIO14) and RX (GPIO15), see the raspberrypi.org GPIO documentation).

On your computer, install screen:

sudo apt install screen
Then open the serial port using screen:
screen /dev/ttyUSB0 115200
Replace /dev/ttyUSB0 with the actual tty the Pi is connected to. 115200 is the baud rate.

Now that you have access to the Pi, you can start configuring the network.

Disabling Cloud Init

By default, Ubuntu Server uses Cloud Init to automatically configure the network. This is useful when installing it on a server that you don't have physical access to, but we want to configure the network ourselves here, so we'll disable it:

sudo bash -c "echo 'network: {config: disabled}' > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg"

Configuring Netplan

Next, create your Netplan configuration:

sudo nano /etc/netplan/10-my-config.yaml
If you just want a simple WiFi and Ethernet configuration, you can use the following:

10-my-config.yaml

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true
      optional: true
  wifis:
    wlan0:
      dhcp4: true
      optional: true
      access-points:
        "Your-WiFi-Network-Name":
          password: "******"

Be sure to fill in your WiFi network details, and then use Ctrl+X to exit. Answer y to the question Save modified buffer? and press enter to confirm the filename.

Finally, generate and apply the configuration:

sudo netplan generate
sudo netplan apply

Configuring the WiFi if you don't have access to the Pi's console

If you can't reach the Pi's console, because you have no Ethernet connection and if you can't connect to the serial port either, you can configure the network by editing the files on the SD card.

Mount the writable partition of the SD card on your computer, and follow the same steps as in the case where you do have access to the console.

sudo bash -c "echo 'network: {config: disabled}' > /media/$USER/writable/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg"
sudo nano /media/$USER/writable/etc/netplan/10-my-config.yaml

Now close the terminal, and safely remove the SD card. You don't have to run any netplan commands, the configuration will be applied automatically when you boot the Pi.