iw
Configure wireless network interfaces
TLDR
Scan for available wireless networks
Join an open wireless network
Close the current connection
Show information about the current connection
List all physical and logical wireless network interfaces
List all wireless capabilities for all physical hardware interfaces
List the kernel's current wireless regulatory domain information
Display help for all commands
SYNOPSIS
iw [options]
iw [options] dev
iw [options] phy
iw help
iw
PARAMETERS
dev <devname>
Specifies a wireless network interface (e.g., wlan0) for the subsequent command.
phy <phyname>
Specifies a physical wireless device (radio) for the subsequent command, typically named phy0, phy1, etc.
list
Lists all available wireless devices and their capabilities.
info
Displays detailed information about the specified wireless device.
scan
Initiates a scan for nearby Wi-Fi access points and displays the results.
connect <SSID>
Connects to a specified Wi-Fi network (SSID).
disconnect
Disconnects from the currently connected Wi-Fi network.
link
Shows the current link state of the wireless interface, including connection status and signal strength.
station dump
Lists all connected stations when the interface is in AP (Access Point) mode.
interface add <name> <type>
Adds a new virtual wireless interface of a specified type (e.g., monitor, ap).
interface del <name>
Deletes an existing virtual wireless interface.
set <option> <value>
Sets various device parameters, such as channel, transmit power, or powersave mode.
monitor
Sets the device to monitor mode, allowing capturing of all Wi-Fi traffic.
help
Displays general help or specific help for a given command.
DESCRIPTION
iw is a command-line utility for configuring wireless devices in Linux. It is the modern replacement for the deprecated iwconfig tool, leveraging the nl80211 kernel subsystem for wireless configuration. Unlike iwconfig, which used a more ad-hoc approach, iw provides a consistent and extensible interface for managing various aspects of Wi-Fi.
It allows users to control physical wireless devices (phys) and their associated network interfaces. With iw, you can perform a wide range of operations, including listing available Wi-Fi devices, scanning for nearby access points, connecting to and disconnecting from networks, configuring interface modes (such as managed, AP, monitor, or mesh), managing virtual interfaces, and setting advanced parameters like channel, transmit power, and power-saving modes. It's an essential tool for administrators and users needing fine-grained control over their wireless adapters, especially in environments where NetworkManager or similar services are not used, or for debugging purposes.
CAVEATS
The iw command requires kernel and driver support for the nl80211 (Netlink protocol for 802.11 wireless devices) subsystem. It is designed to replace iwconfig but is not a direct drop-in replacement; its syntax and command structure are significantly different. Most operations require root privileges or appropriate sudo permissions. Functionality might vary based on the specific wireless adapter and its driver's support for nl80211 features.
INTERFACE TYPES AND MODES
Wireless interfaces can operate in various modes, each suited for different purposes. Common modes include:
managed (client mode, connecting to an AP),
AP (Access Point mode, allowing other devices to connect),
monitor (passive listening for all Wi-Fi traffic),
mesh (for ad-hoc mesh networks), and
IBSS (Ad-Hoc mode, for direct peer-to-peer communication).
The iw command allows adding and configuring virtual interfaces for these different modes on a single physical radio.
PHYSICAL DEVICES (PHY)
In iw, a 'phy' refers to a physical wireless radio. A single physical radio can support multiple virtual interfaces operating simultaneously in different modes (e.g., one in managed mode, another in monitor mode). Commands affecting the entire radio, like setting regulatory domains or listing capabilities, are often performed using the iw phy command. Interfaces are typically named wlan0, wlan1, etc., while physical devices are phy0, phy1, etc.
HISTORY
The iw command was developed as the modern successor to the older iwconfig utility. Its creation was driven by the need for a more robust and extensible wireless configuration tool that leverages the nl80211 kernel interface, which superseded the older Wireless Extensions API used by iwconfig.
iw is part of the wireless-tools lineage but represents a fundamental shift in how wireless devices are managed in Linux, providing a more consistent and powerful way to interact with contemporary Wi-Fi hardware and drivers. It was designed from the ground up to support advanced 802.11 features and address limitations inherent in the previous generation of tools.
SEE ALSO
iwconfig(8), ip(8), wpa_supplicant(8), hostapd(8), nmcli(1)