iw · Linux command

Also known as: iw command

On this page 7

iw is the Linux command for configuring and inspecting wireless network devices, communicating with the kernel through the nl80211 netlink interface and the cfg80211 wireless subsystem. In Linux networking, it replaced the older iwconfig utility from the Wireless Extensions era and exposes modern IEEE 802.11 features such as virtual interfaces, mesh networking and detailed station statistics.

The iw command works at the wireless link layer: it shows which networks are in range, which access point a card is associated with, which channel and bandwidth are in use, and what the hardware supports. It does not assign IP addresses or handle WPA authentication, which belong to tools such as the ip command and wpa_supplicant.

How iw talks to the wireless stack

The iw utility sends netlink messages to the nl80211 family, which the kernel’s cfg80211 layer translates into calls to the wireless driver. Modern drivers built on the mac80211 framework, which implements the 802.11 MAC in software, expose nearly all iw features, while full-MAC drivers that handle the MAC in firmware may support only a subset.

iw distinguishes two kinds of objects. A phy (for example phy0) represents the physical radio and its capabilities, while a dev (for example wlan0 or wlp2s0) is a network interface created on top of that radio. One phy can host several virtual interfaces, such as a station and an access point, when the hardware allows the combination.

The table below shows how iw fits into the layered wireless architecture on Linux.

LayerRoleExample component
User-space toolBuilds and sends configuration requestsiw, wpa_supplicant, hostapd
nl80211Netlink API for wireless configurationGeneric netlink family nl80211
cfg80211Kernel configuration and regulatory layerShared by all modern drivers
mac80211Software 802.11 MAC implementationUsed by many SoftMAC drivers
Driver and firmwareControls the radio hardwareiwlwifi, ath9k, mt76
Layers involved when iw configures a wireless device

Essential iw subcommands

Most iw usage follows the pattern iw dev <interface> <command> or iw phy <phy> <command>, with a few global commands such as iw list and iw reg get. Commands that change state require root privileges or the CAP_NET_ADMIN capability, while many read-only queries work for ordinary users.

The following table lists the subcommands administrators use most often.

CommandPurposeTypical output
iw devLists wireless interfaces and their physInterface name, type, channel, MAC address
iw dev wlan0 linkShows the current associationBSSID, SSID, signal in dBm, bitrate
iw dev wlan0 scanPerforms an active scan for networksBSS entries with channel and security
iw dev wlan0 station dumpShows per-station statisticsBytes, retries, signal, inactive time
iw list or iw phyDisplays hardware capabilitiesBands, channels, supported modes
iw reg getShows the regulatory domainCountry code and permitted power
Frequently used iw subcommands

The output of iw is explicitly documented as not stable for scripting, because field names and layout may change between versions. Scripts that need reliable parsing should read sysfs, use a netlink library, or rely on higher-level tools such as nmcli from NetworkManager.

Interface types and operating modes

iw controls the interface type, which defines how a wireless interface behaves on the air. The command iw dev wlan0 set type monitor switches a card into monitor mode, and iw phy phy0 interface add mon0 type monitor creates an extra virtual interface without disturbing the existing station.

The supported combinations are listed under valid interface combinations in the output of iw list, and they vary considerably between chipsets. The table summarizes the common types.

TypeBehaviorTypical use
managedClient station joining an access pointLaptops and desktops on Wi-Fi
__apAccess point role, normally driven by hostapdRouters and hotspots
monitorCaptures all frames on a channelPacket analysis with tcpdump
mesh pointIEEE 802.11s mesh participationCommunity and backhaul meshes
IBSSAd hoc network without access pointLegacy peer-to-peer links
P2P client or GOWi-Fi Direct rolesDevice-to-device connections
Wireless interface types managed by iw

Some types are only meaningful together with a user-space daemon. An interface can be set to the AP type, but beaconing, association handling and WPA2 or WPA3 key exchange are performed by hostapd, not by iw itself.

iw covers wireless-specific configuration only, so it is usually combined with other networking tools rather than replacing them. Understanding the boundaries prevents a common mistake: expecting iw to connect to a protected network on its own.

The comparison below separates the responsibilities of iw and its closest neighbors in Linux networking.

ToolScopeHandles WPA authentication
iwWireless link, modes, channels, scansNo
iwconfigLegacy Wireless Extensions configurationNo, and deprecated
ip commandAddresses, routes, link stateNo
wpa_supplicantClient authentication and key managementYes
nmcli and nmtuiConnection profiles through NetworkManagerYes, through wpa_supplicant or iwd
Division of responsibilities among Linux wireless tools

iw can join an open network directly with iw dev wlan0 connect <SSID>, and it can still configure static WEP keys for legacy setups. For any WPA2 or WPA3 network, however, a supplicant such as wpa_supplicant or iwd performs the four-way handshake, and iw remains useful for diagnosis.

Troubleshooting and common pitfalls

iw is a primary diagnostic tool for weak or unstable Wi-Fi because it exposes signal strength in dBm, bitrates and retry counters directly from the driver. A signal around -50 dBm is excellent, values near -70 dBm are usable for most traffic, and links below -80 dBm tend to suffer frequent retries and rate drops.

  • Changing the channel or type while a manager is running often fails or is reverted, because NetworkManager or iwd reclaims the interface.
  • Interface must be down for many type changes, so ip link set wlan0 down usually precedes iw dev wlan0 set type.
  • Wrong regulatory domain hides channels or limits transmit power; iw reg set only requests a change, and the final domain may follow the access point or firmware.
  • Scan results may be cached or empty when the interface is busy; repeated scans or iw dev wlan0 scan flush give fresher data.
  • Power saving set with iw dev wlan0 set power_save on can add latency on some chipsets.

When behavior differs from expectations, checking iw list first is the decisive step, because many apparent failures are simply unsupported modes or interface combinations on that particular chipset.

Put simply

Think of a Wi-Fi card as a radio. The iw tool is the control panel for that radio on a Linux computer. It shows which networks are nearby, how strong the signal is, and which channel the radio is tuned to.

It can also switch the radio into special roles, such as listening to all nearby traffic or acting as part of a mesh. What it does not do is handle passwords or internet addresses; other tools take care of those. In short, iw manages the radio itself, not the whole connection.

In practice

A network technician at a warehouse receives complaints that handheld scanners lose connection in one aisle. Using a Linux laptop, the technician runs iw dev wlan0 link while walking the aisle and watches the signal fall from -55 dBm to -82 dBm, with the bitrate dropping from 400 Mbit/s to under 20 Mbit/s.

A scan with iw dev wlan0 scan then shows three access points on channel 6 in the 2.4 GHz band overlapping in that area. The technician creates a monitor interface with iw phy phy0 interface add mon0 type monitor and captures frames with tcpdump, confirming heavy retransmissions.

After the facility team moves one access point to channel 1 and enables 5 GHz coverage, repeated measurements show signal above -65 dBm along the whole aisle. The outcome is stable scanner connections and a documented baseline for future surveys.