Commands / Logging in to the network

Logging in to the network

hostapd_cli

Also hostapd, authenticator, 802.1x switch, list_sta, deauthenticate

Asks hostapd, on an access point or as a switch port's 802.1X authenticator, about the devices it serves.

hostapd keeps an 802.1X state machine per device ("station"). all_sta lists each one by MAC with flags=[AUTHORIZED] once RADIUS accepted it, the user name (dot1xAuthSessionUserName), the EAP method and counters of EAPOL frames and RADIUS answers. With -a SCRIPT it runs a script on each event (AP-STA-CONNECTED, AP-STA-DISCONNECTED), which is how a software switch can open and close a port.

On a Wi-Fi access point, status shows its state (ENABLED once it beacons), channel and freq, list_sta prints the MAC address of every station joined, and deauthenticate MAC sends one away with a deauthentication frame, the way a wireless controller moves a client that holds on to a far AP.

hostapd_cli command usage

hostapd_cli [-p DIR] -i PORT all_sta|sta MAC
hostapd_cli [-p DIR] -i PORT -a SCRIPT
hostapd_cli -i wlan0 status|list_sta|deauthenticate MAC

Options

-p /run/hostapd
where hostapd's control sockets are
-i PORT
the port (interface) to ask about
all_sta
every device on the port, with its 802.1X state
-a SCRIPT
run SCRIPT with port, event and MAC on each event
status
an access point's state, channel and frequency
list_sta
the MAC address of every station joined to the access point
deauthenticate MAC
send that station a deauthentication frame, and forget it

hostapd_cli examples

hostapd_cli -p /run/hostapd -i laptop all_sta
Shows who is logged in on the laptop's port, as which user and with which EAP method.
hostapd_cli -i wlan0 list_sta
Lists the stations joined to the access point on wlan0.
hostapd_cli -i wlan0 deauthenticate 02:4e:47:00:00:40
Sends that station away: it picks an access point again.

Pitfalls

  • A device that only stops its supplicant stays AUTHORIZED until it logs off, its link drops or the next reauthentication fails.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab