Linux for WiFi Engineers: Interface Status

By March 13, 2019Linux

In our series “Linux for Network Engineers” we have been focusing mainly on subjects that are of interest to network engineers. In the following weeks we’ll cover some subjects with a slightly narrower focus on the WiFi-related aspects of Linux.

Let’s start by looking at what information we can extract about the WiFi interfaces on a Linux box.

wireless-tools

‘wireless-tools’ is a package that has been around since 2003 and includes a number of commands that can be used to extract different pieces of information. To install it, use:

Let’s review some of its commands:

To refresh your memory when we use commands like ifconfig or ip link show we get only layer 2 and layer 3 information as well some information about the physical layer (e.g. if the interface is up and running).

However, we don’t see any information regarding the BSSID that it’s connected to, the signal strength, or the channel.

iwconfig

iwconfig is reminiscent of ifconfig, but it gives more layer 1 information about any WiFi interfaces. Here is what the output looks like:

It tells us which protocol it’s using (IEEE 802.11), which ESSID it’s connected to (netbeez), the frequency (5.66 GHz), BSSID (38:3B:C8:3E:D4:3A), etc. All of this information is necessary when we are looking to extract the status and quality of our WiFi connection.

iwconfig can also be used to manipulate an interface (e.g. connect it to an SSID or specific channel), but we’ll cover that in another blog post since here we are looking only at what information we can extract.

iwgetid

The output that iwgetid provides overlaps with the output from iwconfig, but it has a neat feature that lends itself to parsing its output in a script. Let’s start with the options it gives us:

All this information is included in the output of iwconfig, but let’s look at iwgetid’s output format. We’ll try to get the BSSID of the access point it’s connected to:

And let’s run the same command by adding the “–raw” option:

iwgetid returns the output without any additional text or comments; this is very convenient when we want to parse the output. You can also parse the output of iwconfig, but it may get quite hairy in certain cases.

iwlist

iwlist gives the most detailed information and, again, its output overlaps with the previous two commands. Let’s look at some unique features it has: First of all, if you type “iwlist” without any options, you get the list of interface information it can provide:

One feature that is unique to iwlist is that it can give us a list of all supported channels of the WiFi interface as follows:

wireless-tools is considered deprecated, however, it’s also installed by default in many popular distributions, so it’s useful to know it exists and how you can use it.

The most useful feature of iwlist is its scanning option as follows:

iwlist scans the air and lists all detected SSIDs with information such as signal strength, link quality, supported bitrates etc. This is useful when you want to manually connect to a specific SSID, while finding one with a good signal strength, on a specific channel, or a specific BSSID.

iw

iw is the replacement of wireless-tools and it can give all the information we see above and then some more. It’s a tool from 2012 and is actively maintained. You can install it with:

It doesn’t contain multiple commands, but rather just one command with many different options. If you type “iw –help” you will see pages and pages of options.

The counterpart of iwconfig is the following:

Similar to iwlist, iw can give the capabilities of the hardware in terms of which channels it supports, what encryption methods it uses, etc, as follows:

I truncated the output because it can span multiple pages. Compared to iwlist, iw gives a much more detailed and comprehensive list of the hardware capabilities all in one output.

Finally, iw can scan the air for all available SSIDS:

Again, iw gives much more information about the available SSIDs and their access point compared to iwlist.

If you are new to using these commands, I’d suggest to start using iw which is newer and gives much more information than the wireless-tools commands. It’s also actively maintained and supports newer drivers compared to the deprecated wireless-tools.