Fix: USB WiFi on Ubuntu Server (a.k.a Realtek usb [r8188eu]) doesn't work.

Ivan Molina Rebolledo
- 2 min read

So, I really wanted to use Ubuntu Server 20.04 with an old machine that I don't use anymore, because Fedora Desktop didn't work that well as a server; or maybe it is just that I'm more used to work with Ubuntu, idk. Anyways, WiFi was working fine in Fedora, unlike Ubuntu, which brought me a lot of awful problems.

I'm really sure that this isn't the case with Ubuntu Desktop, since it manages all the network in a different way afaik. And I also know that my device works on Desktop without problems.

This is the problem (told by syslog):

Jan 30 17:12:43 ubuntuserver-home kernel: [   12.517740] usbcore: registered new interface driver r8188eu
Jan 30 17:12:43 ubuntuserver-home kernel: [   12.824418] r8188eu 1-1.2:1.0 wlxd037454b3008: renamed from wlan0
Jan 30 17:12:43 ubuntuserver-home systemd-networkd[857]: wlxd037454b3008: Interface name change detected, wlxd037454b3008 has been renamed to wlan0.
Jan 30 17:12:43 ubuntuserver-home systemd-networkd[857]: wlan0: Interface name change detected, wlan0 has been renamed to wlxd037454b3008.
Jan 30 17:21:22 ubuntuserver-home wpa_supplicant[2083]: nl80211: Driver does not support authentication/association or connect commands
Jan 30 17:21:22 ubuntuserver-home wpa_supplicant[2083]: nl80211: deinit ifname=wlxd037454b3008 disabled_11b_rates=0
Jan 30 17:25:47 ubuntuserver-home wpa_supplicant[2204]: nl80211: Driver does not support authentication/association or connect commands
Jan 30 17:25:47 ubuntuserver-home wpa_supplicant[2204]: nl80211: deinit ifname=wlxd037454b3008 disabled_11b_rates=0
Awful log, innit?

SO:

  • No-Carrier/Configuring
  • The interface (WiFi) does not appear to be running.
  • Installed the 8188eu drivers from lwfinger/rtl8188eu, but still doesn't work.

The problem is netplan.

Certain WiFi drivers need the "wext" driver from wpa_supplicant, in order to work. The current versions of netplan in Ubuntu Server LTS doesn't specify a driver fallback, so wpa_supplicant tries to use nl80211, as you can see in the log.

# wpa_supplicant should be run as
sudo wpa_supplicant -Dwext -c configurationfile.conf -i interface

# but netplay uses
sudo wpa_supplicant -c configurationfile.conf -i interface
#which defaults to nl80211

There is not a so easy fix. And so far there is no way to set a driver in netplan. But I found a dirty fix to this.

The mainline git repo already includes a fix in which fallback options are hardcoded, so it'll work for us, but not for people using more strange wpa_supplicant drivers.

The solution is to use this repo. And we'll trick apt so it thinks that netplan is installed from the repos, yeah. But hey, it works.

You're using Ubuntu Server, I suppose you don't need an explanation of the following:

sudo apt install libglib2.0-dev libyaml-dev libsystemd-dev pandoc #netplan build dependencies
sudo dpkg -r --force-depends netplan.io #Without deleting ubuntu-minimal
sudo dpkg -r --force-depends libnetplan0 #Same
sudo apt-mark hold netplan.io
sudo apt-mark hold libnetplan0
git clone https://github.com/canonical/netplan.git
cd netplan
make
sudo make install

#Check that is working
sudo netplan generate

And that's all. It should work.

Oh, and btw, it'll only work out-of-the-box like this if you are using an static ip for your WiFi configuration on /etc/netplan/

If you don't want to use a static ip for Ubuntu Server because you're a little weird (just like me), you can make a systemd service so dhclient starts for our WiFi interface on boot.

So:

sudo vim /etc/systemd/system/dhclientwifi.service 
[Unit]
Description=DHCP Wifi
Wants=netplan-wpa-wlxd037454b3008.service
After=netplan-wpa-wlxd037454b3008.service

[Service]
Type=forking
ExecStart=/sbin/dhclient wlxd037454b3008 -v
ExecStop=/sbin/dhclient wlxd037454b3008 -r
Restart=always

[Install]
WantedBy=multi-user.target

You're obviously going to replace wlxd037454b3008 with your own network interface, just as is in the /etc/netplan/ configuration.

And that's all. Just restart your "server".

If you have any problem with this, let me know. I learned a lot from figuring out how to solve this problem.