3

I first came across this when I was trying to make a python program that used programs to scan for wireless networks. I've used the following tools:

iwlist, iw, wpa_cli, nmcli, and iwconfig

I run into the same behavior on all of them. Suppose you're sitting by your computer and wireless access point/router. Type out one of the following commands, assuming your wifi adapter is named wlan0, turn of the router, then press enter in the terminal window.

iw wlan0 scan | grep SSID
iwlist wlan0 scan | grep SSID
wpa_cli -i wlan0 scan && wpa_cli -i wlan0 scan_results
nmcli device wifi rescan && nmcli device wifi list

All of the commands still show the SSID for quite some time. I imagine longer than it would take for the E&M standing wave to disappear. Does anyone have any fix for this problem?

1
  • On which wlan was connected your scanning PC? Did you cleanly shutdown the SSID wlan? Did you check (arp or tcpdump) the SSID wlan was shut?
    – athena
    Commented Feb 12, 2018 at 15:03

3 Answers 3

4

In the default configuration wpa_supplicant might display scan results that have been cached for some time.

Add this line to your wpa_supplicant.conf file to have the scan results only show those SSIDs that were detected during the previous scan:

ignore_old_scan_res=1
2

I solved this quite awhile ago, my apologies for leaving it unanswered. The following wpa_supplicant settings are responsible for the wifi behavior mentioned above:

bss_expire_count and bss_expire_age

The former is how many scans the SSID has to be missing from before it removes it from the list. The latter is the time in seconds to display an SSID after it's no longer broadcasting

0

None of the above worked for me. The only consistent way I've found to make powered-off networks not show up in wifi scan results is to reload the wireless interface's kernel module, which completely flushes all cached results from prior scans.

To follow this strategy in a shell script, just include these lines:

# as appropriate for your system:
iface=wlan0

# reload kernel module:
module=$(basename $(readlink -f /sys/class/net/$iface/device/driver/module))
modprobe -r $module
modprobe $module

# bring interface back up:
ifconfig $iface up

# scan for hotspots using your preferred method (I happen to like iwlist):
iwlist $iface scanning

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .