Let's say I have a problem with my wireless connection. What commands should I run to share their output with a tech-savvy friend or an online support community?
For example:
- How can I tell if my wireless card is recognised?
- How can I get information on which wireless networks are within range?
- How can I tell if I am connected to a wireless, but not the Internet?
I'm asking this question because I'm seeing many questions about problems with wireless connections, without many details, like this one. It would be useful if I could point to this question so that the asker can improve their question with more information. I'm hoping for a comprehensive answer with all the details, or with links to other generic questions for brevity.
To check if the card is recognized, run:
or
The second command is useful, as it shows the vendor and product IDs [8086:4222]:
Example - card recognized, brand and model are correctly identified, correct driver is in use (driver=iwl3945), and wireless connection is established (ip=192.168.2.81):
To make sure you are connected to a wireless, but not an ethernet network, first identify the wireless interface (usually wlan0, eth1 or eth2) by looking at the output of
sudo lshw -C network
. Then, look for an IP address to tell which interface is connected.The ability to experiment rapidly is the best approach for a quick diagnosis.
Two diagnostic tools I find invaluable to pinpoint the root cause in cases where the WiFi works, but is unreliable, e.g. intermittently losing the connection, sessions hanging, web-pages freezing are
iwlist
andmtr
.Here's how to use
iwlist
andmtr
effectively:1) Is the low-level wireless reception/transmission healthy?
This gives a treasure trove of information about the strongest wireless signals detected by your card. I find the
Channel
,Frequency
,ESSID
,Quality
, andSignal level
, the most useful.If you have no signal, or your ESSID isn't recognized, you need to focus on the low-level (hardware/drivers): Is the router on? Are antennas oriented optimally? Is device too far away from the router? Do you have the right driver for your wifi card? (for that you may want to check the system logs)
Assuming the ESSID is known and the quality is good (say about 30%-100% of the maximum) you may move to the second, higher level, stage:
2) Once a WiFi connection is established, is the connection stable?
Since TCP/IP supports error-detection with retransmits, and congestion control, WiFi disconnects/reconnects are usually a result of a large number of errors to the point where TCP gives-up. Rather than waiting for a full disconnect, which may happen only once in several minutes, I run
mtr
in a separate window and continuously watch theLoss%
(packet percent loss) andAvg
(average round-trip time in milliseconds) columns:While looking at this screen, I can immediately see not just whether there's some ongoing transmission/reception problem, but also which link along the way is the most problematic/slow one, in case there's more than one hop between me and the target
<hostname>
.(If you don't have
mtr
installed, you may install it using:sudo apt-get install mtr
)I find these two tools particularly valuable because they provide a continuous state of the WiFi connection. I can quickly change configuration and immediately see the effect of my change on the network. Some examples of experiments you may do while looking at the above described screens are:
/etc/network/interfaces
and thenifdown wlan0 && ifup wlan0
modprobe <name_of_device_driver>...
service networking restart
ifconfig wlan0 mtu 1472
As there are so many knobs you can turn and experiment with, the most critical thing, is to be able to see the immediate effect of any change on the continuously updating screens. If it makes no difference (most cases, in my experience), just note it down, and revert to the previous state. But if you suddenly see the
Loss%
rates jump up inmtr
, or the signal strength sharply drop (or conversely, jump way up) iniwlist
, you know you've found a smoking gun (or the fix).Again, the #1 take-away from all of this is: Rapid experimentation is the key to be able to quickly diagnose WiFi issues