How to Enable Wi-Fi on Ubuntu Server 20.04 without a Wired Ethernet Connection

Yu Ping
4 min readSep 24, 2020

Almost every personal computer (laptop or desktop) that meets the minimum hardware requirements can run the Linux server operating system. It makes no surprise that many people set up their home servers on some old but still working personal computers for self-learning or side projects.

One of the common options of running a home-based Linux server is to access the server via an existing Wi-Fi home network. The Linux server installation software, in general, does not include wireless network support packages, so it relies on the user to enable the Wi-Fi connection.

In this post, I will show you the steps to set up and configure the Wi-Fi access using WPA supplicant and netplan on Ubuntu Server 20.04 without a wired ethernet connection.

Step 1: Download WPA Supplicant Package and Its Dependencies

Since the server has no wired ethernet connection, you need to download the WPA supplicant package (wpasupplicant) and two of its dependencies (libnl-route-3–200, libpcsclite1) on another machine with an internet connection, then transfer them to the server using a flash/external drive.

wpasupplicant: client support for WPA and WPA2 (IEEE 802.11i).

http://mirrors.kernel.org/ubuntu/pool/main/w/wpa/wpasupplicant_2.9-1ubuntu4_amd64.deb

libnl-route-3–200: library for dealing with netlink sockets — route interface.

http://mirrors.kernel.org/ubuntu/pool/main/libn/libnl3/libnl-route-3-200_3.4.0-1_amd64.deb

libpcsclite1: middleware to access a smart card using PC/SC (library).

http://mirrors.kernel.org/ubuntu/pool/main/p/pcsc-lite/libpcsclite1_1.8.26-3_amd64.deb

You can use the following command to download the packages if another machine is also running Ubuntu Server 20.04 and has not installed WPA supplicant package:

sudo apt install -y --download-only wpasupplicant

The deb files of wpasupplicant and its dependencies are downloaded in the following directory by default:

/var/cache/apt/archives/

If that machine is running Ubuntu Server 20.04 but has already installed WPA supplicant package, you can use dpkg-repack to re-create the deb files:

sudo apt install -y dpkg-repack
sudo dpkg-repack wpasupplicant libnl-route-3–200 libpcsclite1

Now, copy these three deb files to your flash/external drive.

Step 2: Install WPA Supplicant Package

Find the device name for the flash/external drive (e.g. USB stick) after you plug it into the server:

sudo fdisk -f

A USB flash disk is usually listed at:

/dev/sdb1

Create a new directory and mount the flash/external drive:

sudo mkdir /media/usb
sudo mount -t vfat /dev/sdb1 /media/usb

Install WPA supplicant package and its dependencies:

cd /media/usb
sudo dpkg -i libnl-route-3–200_3.4.0–1_amd64.deb \
libpcsclite1_1.8.26–3_amd64.deb \
wpasupplicant_2.9–1ubuntu4_amd64.deb

Step 3: Find Wireless Interface Name

The Linux kernel lists network interface names via symlinks in /sys/class/net, whereas the wireless network interfaces are named wlp2s0, wlp3s0, and so on:

ls /sys/class/net | grep -i wlp

There are many alternative options to find the wireless interface in Linux. I list a few examples below:

# Use ip command: ip link or ip addr
ip link show | grep -i wlp | awk -F: '{print $2}' | xargs
ip addr show | grep -i wlp | awk -F: '{print $2}' | xargs
# Use iw tool
iw dev | awk '$1=="Interface" {print $2}'
# Use lshw to check wireless adapters
sudo lshw -C network \
| awk '/Wireless interface/,/logical name/ {print $3}' \
| tail -1

Step 4: Create a NetPlan Configuration File

To configure netplan, make a copy of the existing configuration file, then create a new one under /etc/netplan/ with a .yaml extension:

sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00.bak
sudo vim /etc/netplan/00-installer-config.yaml

To let the wireless interface named wlp2s0 get an IP address via DHCP, edit the YAML file with the following:

network:
ethernetes: {}
wifis:
wlp2s0:
dhcp4: true
optional:true
access-points:
"network_ssid_name":
password: "**********"
version: 2
renderer: networkd

To instead set a static IP address:

network:
ethernetes: {}
wifis:
wlp2s0:
dhcp4: no
dhcp6: no
optional:true
addresses: [192.168.1.22/24]
gateway4: 192.168.1.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
access-points:
"network_ssid_name":
password: "**********"
version: 2
renderer: networkd

Adjust the wireless interface name, static IP address, gateway, name servers and Wi-Fi SSID/password as required.

Note the optional: true key declarations which allow booting to occur without waiting for those interfaces to activate entirely.

Step 5: Apply the Netplan Configuration

Once you finish editing the netplan YAML file, generate backend configuration from it and check whether the configuration supplied meet the defined standards:

sudo netplan --debug generate

If everything is in order, apply the configuration provided for use:

sudo netplan apply

Now, reboot the server:

sudo reboot

Final Notes

If the wireless interface name is not displayed, the wireless adapter may not have been recognized as a server’s network device. You can head over to the Ubuntu help site to get the specific troubleshooting information:

https://help.ubuntu.com/stable/ubuntu-help/net-wireless-troubleshooting-hardware-check.html.en

The netplan YAML file is very fussy about indentation, spacing, and no tabs. See the following link for additional help:

https://netplan.io/examples

Please make sure you enter the correct Wi-Fi SSID and password in the netplan YAML file. The netplan apply command will succeed, but the wireless interface will not be up if you supply an incorrect Wi-Fi SSID or password.

Thank you for reading!

--

--

Yu Ping

Infrastructure Engineer | Certified Kubernetes Administrator (CKA)