What is iwconfig?
While standard commands like ifconfig or ip addr provide information about Ethernet and IP configurations, they are largely useless for wireless troubleshooting. The iwconfig command is specifically designed to interact with the wireless extensions of the Linux kernel, allowing you to view and modify Wi-Fi specific parameters such as the SSID, frequency, transmit power, and signal quality of your wireless network interfaces.
Step 1: Identify Your Wireless Interfaces
To begin, you need to identify the name of your wireless network adapter. Open your terminal and run iwconfig without any arguments:
iwconfig
The output will list all network interfaces. Ethernet interfaces (like eth0 or enp3s0) will simply state “no wireless extensions.” Look for the interface that displays wireless data, typically named something like wlan0 or wlp2s0.
Step 2: Read the Wireless Status Output
Analyze the output for your wireless interface. Pay close attention to the following fields to diagnose performance issues:
- ESSID: The name of the network you are currently connected to.
- Frequency / Channel: The radio frequency being used (e.g., 2.4 GHz or 5 GHz). This is crucial for avoiding channel interference.
- Bit Rate: The current theoretical maximum speed of the connection based on signal strength.
- Link Quality / Signal level: The physical strength of the connection to the router. A low signal level (e.g., lower than -70 dBm) indicates a weak connection that will cause packet loss.
Step 3: Continuously Monitor Signal Strength
If you are trying to find a dead zone in your office or position a router for optimal coverage, running a single command isn’t helpful. You can combine iwconfig with the watch command to monitor your signal strength in real-time updating every second:
watch -n 1 iwconfig wlan0
Walk around with your laptop and watch how the “Signal level” and “Link Quality” fluctuate as you move further from the access point.
Step 4: Modify Transmit Power (Tx-Power)
In some scenarios, you may want to increase the transmit power of your Wi-Fi card to reach a distant router, or decrease it to save battery life. (Note: The maximum legal transmit power is regulated by your country). To change the Tx-Power to 15 dBm, run:
sudo iwconfig wlan0 txpower 15
Step 5: Disable Power Management
A common cause of dropped Wi-Fi connections or latency spikes on Linux laptops is the aggressive Wi-Fi power management feature, which puts the wireless card to sleep to save battery. If you are experiencing unstable ping times, you can disable power management entirely for that interface:
sudo iwconfig wlan0 power off
Test your connection again to see if stability improves.