close
close

How to Use Terminal to Troubleshoot Wi-Fi Problems on Linux

  • Linux users can solve most Wi-Fi problems using terminal commands, without having to download any software.

  • Resetting the IP address or network interface using terminal commands can solve common Wi-Fi problems.

  • If problems persist, contact your Internet Service Provider for assistance.

If you’re having Wi-Fi issues, chances are they can be easily resolved. If you’re using a Linux PC, it’s even easier because you can fix the most common Wi-Fi problems with a few quick terminal commands, without having to download any software.

If you’re new to Terminal or even Linux as a whole, don’t worry as you can’t do any permanent damage to your systems. You shouldn’t really be afraid of the terminal, because that’s where Linux’s strength lies, as you’ll soon see.

IP address release and renewal

Often, Wi-Fi problems are caused by problems with your IP address, which is a set of numbers that identifies your location on the Internet. There can be many reasons for this, but fortunately the solution is always the same, namely resetting the IP address.

To do this, you must first know your current IP address. This can be done with the following command:

ip address

Alternatively, some Linux distributions will allow you to do this in a graphical environment. Check out our article on how to find your IP address in Ubuntu.

Although it is not necessary, you may want to make a note of this IP address as we need to check if it has changed once we are finished.

We then need to request a new IP address via your DHCP server. We have a full explanation of what DHCP is, but the short version is that it is a protocol that handles the allocation of IP addresses. It usually does this every day, so your network gets a new IP address every 24 hours. We are going to ask if we can renew it now.

To do this, you need a program called dhclient, which is installed by default on Linux systems. Run it to find out what’s currently running on your system, using the “verbose” (-v) command to make sure you get some output:

sudo dhclient -v
Full output from dhclient.Full output from dhclient.

Full output from dhclient.

This lets you know what IP address was requested (DHCPREQUEST) and when it will expire, in my case in 40157 seconds, or about 11 hours.

Now we need to release the IP address, which means we ask dhclient to remove it. This is done with the -ri command, I recommend adding another “full” command to see what happens:

sudo dhclient -v -r
Releasing the IP address in dhclient.Releasing the IP address in dhclient.

Releasing the IP address in dhclient.

Once you have done this, now request a new IP address using the same command as before:

sudo dhclient

Now all you need to do is enjoy your new IP address.

Resetting network settings

However, sometimes renewing your IP address is not enough. The next thing you can try is to completely reset the network interface in the hope that the setting causing the problem returns to its default state.

For this purpose we will use a program called ip. This is a very powerful tool that allows you to control the network operation on your device. We have a full guide on using the ip command, although for now we only need three commands.

The first is to show the interfaces present on your device. To do this, enter:

ip link show
Output of the ip command.Output of the ip command.

Output of the ip command.

You will receive a list of interfaces. For most people this is the second option (enp0s3 in my case), so let’s try resetting this option first. To do this, disable the interface:

sudo ip link set <interface_name> down

This disables the feature, you can check this with the earlier “link show” command.

Interface disabled using the ip command.Interface disabled using the ip command.

Interface disabled using the ip command.

Now you can re-enable the interface:

sudo ip link set <interface_name> up
IP interface restored.IP interface restored.

IP interface restored.

Still can’t solve your Wi-Fi problems?

In most cases, these two fixes should end any problems you may have with your Wi-Fi connection. However, if this is not the case, the problem may lie with your Internet Service Provider (ISP). We recommend that you contact them and check if your location is experiencing internet issues.