Andrew Mercer
on this page

Modern vs legacy tooling

iwconfig/iwlist (the wireless-tools package) are deprecated in favor of iw and, for connection management, nmcli/nmtui — but they're still common on embedded/older systems and worth knowing. This guide covers both the classic CLI tools and the modern iw equivalents.

Identifying the wireless card and driver

sudo lshw -C network
*-network
     description: Wireless interface
     product: <adapter model>
     vendor: <vendor>
     logical name: wlan0
     serial: <mac_address>
     configuration: driver=<driver_name> driverversion=... ip=... wireless=IEEE 802.11ac
basename "$(readlink /sys/class/net/wlan0/device/driver)"    # just the driver name
sudo ethtool -i wlan0                                          # driver/firmware version
sudo modinfo <driver_name>                                     # full module parameter reference

Scanning for access points

Modern (iw):

sudo iw dev wlan0 scan | grep -E "SSID|signal"

Legacy (iwlist):

sudo iwlist wlan0 scan

Both report SSID, channel/frequency, signal quality, and the encryption suite in use (WPA2/CCMP, WPA/TKIP, WEP, or open).

Bringing an interface up and checking status

sudo ip link set wlan0 up      # modern
sudo ifconfig wlan0 up         # legacy, if net-tools installed

iwconfig wlan0                  # legacy status view: ESSID, mode, frequency, bit rate, link quality
iw dev wlan0 link                # modern equivalent

Hardware/software kill switch (rfkill)

rfkill list                 # show current block state for all wireless devices
sudo rfkill block wlan      # soft-block
sudo rfkill unblock wlan    # release the soft-block

A device that won't come up despite correct configuration is worth checking here first — a soft- or hard-blocked radio won't associate no matter how correct the rest of the config is.

WPA-PSK / WPA2-PSK via /etc/network/interfaces (ifupdown)

For systems still using classic ifupdown rather than NetworkManager (embedded boards, minimal installs):

sudo vi /etc/network/interfaces
auto wlan0
iface wlan0 inet dhcp
    wpa-driver nl80211
    wpa-ssid YourSSID
    wpa-ap-scan 1
    # RSN = WPA2, WPA = WPA1
    wpa-proto RSN
    # CCMP = AES, TKIP = legacy/weaker
    wpa-pairwise CCMP
    wpa-group CCMP
    wpa-key-mgmt WPA-PSK
    wpa-psk your_wireless_password
sudo ifdown wlan0 && sudo ifup wlan0

Mixed WPA/WPA2 network

    wpa-proto RSN WPA
    wpa-pairwise CCMP TKIP
    wpa-group CCMP TKIP

Open network (no encryption)

Via wpa_supplicant.conf directly:

network={
        ssid="OpenNetwork"
        key_mgmt=NONE
}

Static IP instead of DHCP

auto wlan0
iface wlan0 inet static
    address 192.168.1.120
    netmask 255.255.255.0
    gateway 192.168.1.1
    wpa-driver nl80211
    wpa-ssid YourSSID
    wpa-proto RSN
    wpa-pairwise CCMP
    wpa-group CCMP
    wpa-key-mgmt WPA-PSK
    wpa-psk your_wireless_password

Resetting a stuck wireless connection

The blunt-force fix that resolves a large fraction of "wireless just stopped working" cases, when the actual root cause isn't worth chasing:

sudo systemctl restart NetworkManager
# or, driver-level reset (replace with your actual driver name from `ethtool -i` above):
sudo rmmod <driver_name> && sudo modprobe <driver_name>

Cheat sheet

sudo iw dev wlan0 scan | grep -E "SSID|signal"    # scan for APs
iw dev wlan0 link                                  # current connection status
rfkill list                                        # check soft/hard block state
ethtool -i wlan0                                   # driver/firmware info
sudo systemctl restart NetworkManager              # reset when stuck

Further reading