Wi-Fi Not Working in Linux? Here’s How to Fix it

A photograph of a window with a Wi-Fi logo on it.

One of the big challenges that users tend to face with Linux is Wi-Fi. Wi-Fi drivers are often not included in the kernel, and as a result, there are many issues getting non-Intel Wi-Fi modules to work well under Linux. Here we cover what happens when Wi-Fi isn’t working on Linux and how to fix it.

Tip: learn how you can find saved Wi-Fi passwords in Linux.

Hardware vs. Software Wi-Fi Issues

A Wi-Fi connection issue can be either a hardware or software issue. Hardware issues are relatively easy to diagnose – all you have to do is to open the terminal and enter the following command:

ping localhost
A terminal showing a localhost loopback test.

This is a simple way to check if your physical hardware is working. localhost works as an address to check the circuitry for your NIC. If this isn’t working, you may need to have some work done on the hardware, whether by yourself or someone else.

If that ping comes back clean or you don’t even see your Wi-Fi card, you likely have a software issue.

Aside from that, you can also check if your system detects an active network interface by running ip addr. Most distros label currently active wireless cards as “wl” followed by the device’s bus and slot numbers in the computer’s motherboard.

For instance, a label of “wlp0s1” means that it’s a wireless network interface on bus 0, slot 1.

A terminal highlighting the wireless device currently running in the system.

Note: If you are unable to browse the web, you may need to disable IPv6 on your Linux machine.

Install Drivers from Ubuntu ISO

If your distro isn’t detecting your Wi-Fi network at all, or if you’re getting errors, then you can try installing or reinstalling the Wi-Fi drivers from the Ubuntu ISO file. First, you need to download the Ubuntu ISO corresponding to your Ubuntu version. (Presumably, you need to download it on a different device or download it using your Ethernet connection on Ubuntu.)

Open a Terminal, then enter the following sequence of commands to mount the Ubuntu ISO to a virtual drive:

sudo mkdir /media/cdrom
sudo mount -o loop ~/Downloads/ubuntu-*.iso /media/cdrom

Go to “Software Updater” from the dashboard, then click the Settings button on the window’s lower left corner.

A screenshot highlighting the "Settings..." button in the Software Updater utility.

Click the Additional Drivers tab, then select the Wireless Network Adapter option and click Apply Changes.

Issue One: Device Not Detected

If the wireless device is not detected by Ubuntu (or any distro for that matter), open a terminal session and type the following command:

sudo lsusb

This command will print all the USB devices currently plugged into your machine. Look for any line that contains either “Wireless Adapter” or “RTL.”

sudo lsusb | grep "RTL"
A terminal showing the currently active USB Wi-Fi device in Linux.

Aside from listing all the USB adapters, you can also probe your system for any PCI wireless devices. To do this, run the following command:

sudo lspci

Just like with the lsusb command, look for any lines on the lspci output that contains either a “Network Controller” or “Ethernet Controller” label.

A terminal highlighting the PCI-based Wi-Fi device in Ubuntu Linux.

Find the exact driver module that your wireless device is currently using by running the following command:

sudo lshw -C network | grep "driver"

Highlight the value of the “driver” variable and copy it to your clipboard.

A terminal highlighting the currently active driver for the Wi-Fi device.

Issue Two: Driver Module Missing

Following on from the successful lsusb and lspci commands, confirming that your Linux distro can see the wireless card, you can assume that the firmware is working, just that the system has no idea what to do with the device. This is where drivers or modules are needed.

Type the following command then replace “modulename” with the contents of your clipboard:

sudo modprobe modulename

For example, if your wireless driver is “iwlwifi,” it would be as follows:

sudo modprobe iwlwifi

After this, run sudo lsmod | grep "modulename" to see if the Linux kernel has loaded your Wi-Fi device correctly.

A terminal showing the Wi-Fi module being loaded into the current kernel.

Load Driver Module Automatically at Boot

It is a rare occasion, but sometimes the module will not persist from boot. In this case, you can force it to load permanently. Enter the command below into the terminal:

sudo nano /etc/modules

Add your module name at the bottom and save the file.

A terminal showing the config file that can load kernel modules at boot time.

Reboot the machine to check if the Linux kernel has loaded the wireless device correctly.

Good to know: learn how your computer manages its hardware by installing your own custom Linux kernel in Ubuntu today.

Issue Three: DNS

It’s rare that the DNS will be an issue; however, it is worth investigating if you still have connection issues. From the terminal, type the following command to check the system’s default DNS resolver:

nmcli device show INTERFACE-NAME | grep IP4.DNS

By default, this will be set to your router’s IP address. If it doesn’t work, you may have to change “wlp0s1” to whatever your wireless uses. The following command can also be used to grab the designation:

ip addr | grep ": "

Once you have this information, ping your DNS resolver’s address. If that works, you can also send a ping to an external network such as Google’s DNS resolvers:

ping 8.8.8.8

If all devices within your network are giving page load errors, then change the DNS resolvers on your router to Google’s or OpenNIC’s servers. You’ll have to consult your router’s manufacturer for how to do this, but it’s generally done by accessing the device’s admin console. You can find this on most routers by going to either “192.168.0.1” or “192.168.254.254” on a web browser.

Adding a Custom DNS Server in NetworkManager

That said, you can also change the DNS resolver on a per-device basis. To do this in Ubuntu, click the Control Menu button on the upper right corner of the desktop then select the Gear icon.

A screenshot highlighting the Settings button in Gnome.

Click the Wi-Fi category, then look for the Visible Networks category.

A screenshot highlighting the visible networks section of the Wi-Fi category.

Select the Gear icon on the line that contains your wireless access point name.

A screenshot highlighting the Settings button for the currently active wireless access point.

Click the IPv4 tab on the smaller window’s upper bar.

A screenshot highlighting the IPv4 tab on the access point settings menu.

Go to the DNS section, then toggle the Automatic switch off.

A screenshot highlighting the DNS "Automatic" switch under the IPv4 tab.

Type “8.8.8.8,8.8.4.4” on the DNS textbox, then click Apply to commit the settings.

A screenshot highlighting the custom DNS resolvers for the current Wi-Fi connection.

Open a new terminal, then run the following command to remove any previous DNS resolver data:

resolvectl flush-caches

Test whether your system is now using its new DNS resolver settings by running the following:

resolvectl status | grep "Current DNS Server"

Check if the current DNS settings resolved your network issue by loading a web page on a web browser.

A screenshot of the MakeTechEasier website on an Ubuntu machine with a custom DNS resolver.

Good to know: learn more about name servers and DNS resolvers by using dig in Linux.

Issue Four: No Network Manager

Let’s say you have removed the Network Manager or uninstalled it by accident. This is a really troublesome situation: you have no Internet and no Network Manager, but there are things you can do.

Assuming the package is still within your cache, you can go to the terminal and enter:

# Debian/Ubuntu
sudo apt install network-manager
 
# Fedora
sudo dnf install NetworkManager
 
# Arch Linux
sudo pacman -Syu networkmanager

If that doesn’t work, you can force your system to connect to a wireless access point by using wpa_supplicant. This is a command line tool that uses your wireless device’s driver to connect to an access point without using Network Manager.

To start, create a configuration file for wpa_supplicant using your favorite text editor:

sudo nano /etc/wpa_supplicant.conf

Paste the following block of code inside the config file, then replace “SSID” and “PASSWORD” with the access point name and password of your router:

network={
    ssid="SSID"
    password="PASSWORD"
}

Save the config file, then paste the following line of code to your terminal session:

sudo wpa_supplicant -B -i INTERFACE-NAME -c /etc/wpa_supplicant.conf -D nl80211

Replace the value of the “-i” flag with the name of your wireless interface.

A terminal highlighting the interface flag.

Note: this command will only work on newer wireless cards. If you’re trying to link an older Wi-Fi card, replace the value of the “-D” flag with “wext.”

Request a new IP address from your router by reloading the DHCP daemon:

sudo dhclient INTERFACE-NAME

Test whether your Wi-Fi connection is now working by pinging an external site:

ping -c 5 maketecheasier.com

Reinstall Network Manager to restore your Linux system’s full Wi-Fi capability:

sudo apt install network-manager

Reboot your machine to load the new Network Manager installation.

Understanding how Wi-Fi modules and kernel drivers work is just the first step in learning how Linux works under the hood. Explore more of the technical side of this operating system by creating a hidden filesystem with Shufflecake.

Image credit: Dreamlike Street via Unsplash and Wikimedia Commons. All alterations and screenshots by Ramces Red.

Is this post useful?
Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.