hostapd_cli and wavemon
One tool for each side of Wi-Fi: hostapd_cli is the command-line remote control of a Linux access point (hostapd), and wavemon is a live ncurses signal monitor on the client. Together they let you see who is connected to your AP and how strong the signal really is.
181.1 Why is it used?
- hostapd turns the Wi-Fi card of a Linux box into an access point; hostapd_cli lets you query and control it without restarting it.
- List connected stations (MAC, bytes, signal) and kick a misbehaving client with deauthenticate.
- Run a script automatically on AP events such as AP-STA-CONNECTED (-a with -B).
- wavemon shows signal level, noise and SNR live on the client, so you can move the laptop/antenna and watch the effect.
- wavemon's scan window finds nearby APs and the least crowded channel.
181.2 How it works
- Both hostapd and hostapd_cli come from the hostapd package (apt/dnf) and run only on Linux.
- hostapd_cli talks to hostapd over a unix control socket, by default in /var/run/hostapd (one socket per interface).
- Commands can be given one-shot as arguments, or you open the interactive prompt (no command) and type them.
- wavemon is a separate package; it reads the radio via nl80211 and usually needs root.
- Without -i, wavemon auto-detects the first wireless interface.
- Step 1
1.hostapd runs LabAP on wlan0, channel 6
- Step 2
2.Phone (00:11:22:33:44:55) and laptop (00:11:22:33:44:66) associate: 2 stations
- Step 3
3.Admin runs hostapd_cli -i wlan0 all_sta over the unix control socket
- Step 4
4.Reply: one MIB block per station (MAC, bytes, signal)
- Step 5
5.Admin runs deauthenticate 00:11:22:33:44:55
- Step 6
6.hostapd sends a deauthentication frame: phone drops, laptop stays connected
hostapd does the real AP work; hostapd_cli only sends text commands and prints replies
- Step 1
1.LabAP (ch 6) keeps sending beacons
- Step 2
2.Laptop runs sudo wavemon -i wlan0
- Step 3
3.wavemon measures every beacon: signal -52 dBm, SNR 40 dB
- Step 4
4.F1 Info screen shows them as bar graphs
- Step 5
5.Move the laptop or antenna: the values update live
181.3 Lab note: no Wi-Fi radio
- The lab container had only lo, cfg80211/mac80211 not loaded and no /sys/class/ieee80211, so no real AP/station output exists.
- Only commands that exit before touching the Wi-Fi driver were run (-v, -h, connection attempts with no hostapd).
- A seccomp profile allowed only unix sockets, so even nc failed.
uname -rzcat /proc/config.gz | grep -E \ '^CONFIG_(CFG80211|MAC80211|UNIX)='grep -cE \ '^(cfg80211|mac80211|mac80211_hwsim) ' \ /proc/modulesls /sys/class/net; ls /sys/class/ieee80211nc -w 1 127.0.0.1 9 </dev/null$ nc -w 1 127.0.0.1 9 </dev/nullnc: socket(AF_INET,1,0): Operation not permitted181.4 hostapd_cli: options
hostapd -vhostapd_cli -vhostapd_cli -h -a<file> run in daemon mode executing the action file based on events from hostapd -r try to reconnect when client socket is disconnected. This is useful only when used with -a. -B run a daemon in the background| Option | Example | Meaning |
|---|---|---|
| -p | -p /var/run/hostapd | Directory that holds the control sockets |
| -i | -i wlan0 all_sta | Which AP interface to talk to |
| -a | -i wlan0 -a act.sh | Run an action script on every hostapd event |
| -B | -B -a act.sh | Run as a background daemon |
| -h | hostapd_cli -h | Usage and full command list |
| -v | hostapd_cli -v | Version (2.10 in the lab, same as hostapd) |
181.5 hostapd_cli: commands
ls /var/run/hostapdhostapd_cli -i wlan0 all_stahostapd_cli -p /var/run/hostapd \ -i wlan0 status$ hostapd_cli -i wlan0 all_staFailed to connect to hostapd - wpa_ctrl_open: No such file or directory$ hostapd_cli -p /var/run/hostapd -i wlan0 statusFailed to connect to hostapd - wpa_ctrl_open: No such file or directory- No hostapd was running, so /var/run/hostapd did not exist and every command failed to open the control socket.
- The official docs have no sample all_sta output, so only the man page syntax is shown below.
hostapd_cli [-p<path>] [-i<ifname>] [-a<path>] [-hvB] [command..] mib Get MIB variables (dot1x, dot11, radius).sta <addr> Get MIB variables for one station.all_sta Get MIB variables for all stations.help Get usage help.interface [ifname] Show interfaces/select interface.level <debug level> Change debug level.license Show full hostapd_cli license.quit Exit hostapd_cli.| Command | What it does |
|---|---|
| mib | MIB variables: dot1x, dot11, radius |
| sta 00:11:22:33:44:55 | MIB variables of one station |
| all_sta | MIB variables of every associated station |
| deauthenticate <MAC> | Kick a client (sends a deauth frame) |
| status | AP status of the interface |
| interface / interface wlan1 | List AP interfaces / switch to another |
| level 2 | Change hostapd debug level |
| help, license, quit | Command list, license, exit the prompt |
181.6 wavemon: options
wavemon -vwavemon -hwavemon -v -h$ wavemon -v -hwavemon 0.9.5Distributed under the terms of the GPLv3. usage: wavemon [ -hgv ] [ -i ifname ] -g Ensure screen is sufficiently dimensioned -h This help screen -i <ifname> Use specified network interface (default: auto) -v Print version details| Usage | Meaning |
|---|---|
| sudo wavemon | Auto-detected wireless interface |
| sudo wavemon -i wlan0 | Use this interface |
| wavemon -g | Check the terminal is big enough |
| wavemon -h / -v | Help or version, then exit |
| LC_NUMERIC=en_US.UTF-8 wavemon | Controls number grouping |
181.7 wavemon: screens and scan sort keys
F1 / i Info: signal, noise, SNR, statsF2 / l Level histogram (time plot)F3 / s Scan window: APs + clientsF7 / p Preferences, ~/.wavemonrcF8 / h HelpF9 / a About: release info, URLsF10 / q Quit| Key (scan window) | Sort by |
|---|---|
| a / d | Ascending / descending (descending lists least crowded channels) |
| e | essid (network name) |
| s | Signal strength |
| c / C | Channel / channel then signal |
| m | MAC address |
| o / O | Open access first / open access then signal |
181.8 Common mistakes
- Reading "Failed to connect to hostapd" as a broken card: it only means the control socket was not found (hostapd not running, or socket elsewhere: use -p).
- Thinking deauthenticate blocks a client forever: it can reconnect immediately; use a deny list in hostapd.conf or deny_acl.
- Running wavemon without root, or on a box with no wireless interface.
- Forgetting -i when the AP has more than one interface.
181.9 Interview tips
- hostapd is the daemon (beacons, authentication, WPA handshake); hostapd_cli is only a client on the unix control socket. Closing it does not affect the AP.
- all_sta lists stations; deauthenticate kicks one, deny_acl blocks one.
- "Failed to connect to hostapd" = control socket missing, check that hostapd runs and the -p path.
- wavemon: F1 info (signal, noise, SNR), F2 histogram, F3 scan; sort keys are first letters (s signal, c channel).