-1

I was wondering if I can detect the disconnection of a station (client) that was connected to an access-point created using dnsmasq and hostapd on the wlan0 interface.

So far, the best solution I have found is to use the following command

iw dev wlan0 station dump

The problem is that when I unplug the cable of the connected device, the command is still showing the device as connected while increasing the "inactive time" value.

PS. the connected devices are ESP8266 modules.

Any tips are appreciated. Thanks!

Shikartoos
  • 11
  • 3

2 Answers2

1

You can't by only using hostapd, or iw tool, because it consider that the device will become reachable again for some time.
You need (or at least, it's the way I did) to check if station is still reachable using an extern command, like ping.
In my case, I used ip neigh show dev wlan0 nud reachable nud delay and compare the mac address with the station list given by iw dev wlan0 station dump

CimCim
  • 48
  • 5
0

you can monitor your syslog, e.g. on openwrt it reports:

Aug 26 21:41:19 192.168.0.245 hostapd: wlan0-1: STA aa:aa:aa:aa:aa:aa IEEE 802.11: deauthenticated due to REASON

Reason can one of these (at least I found these):

Aug 26 19:00:00 192.168.0.1 hostapd: wlan0: STA aa:aa:aa:aa:aa:aa IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)
Aug 26 19:00:00 192.168.0.1 hostapd: wlan0: STA aa:aa:aa:aa:aa:aa IEEE 802.11: deauthenticated due to local deauth request
Aug 26 19:00:00 192.168.0.1 hostapd: wlan0: STA aa:aa:aa:aa:aa:aa IEEE 802.11: deauthenticated due to inactivity

For this to work, you have to monitor, if the station is successfully connected, e.g.

Aug 26 19:00:00 192.168.0.1 hostapd: wlan0: STA aa:aa:aa:aa:aa:aa WPA: group key handshake completed (RSN)
recycler
  • 1,301
  • 9
  • 9