Script for scanning for available wireless network


My current job deals with deploying wireless network (WiFi), and part of my job routine is to scan and get some details of the available access points (APs) in the area. This simple script is useful if one can’t get Kismet running, and also as in my case, when Kismet is considered an overkill for this simple task.

As my laptop is using Atheros wireless chipset, the kernel module to reload would be different if you’re using different chipset, and wlanconfig is an Atheros specific program and is available in madwifi-utils package (madwifi-ng-tools in Gentoo).

#!/bin/bash

echo "### Initializing driver.."
sudo modprobe -r ath_pci
sudo modprobe -r wlan_scan_sta
sudo modprobe ath_pci
sudo ifconfig ath0 down
sudo ifconfig ath0 up
echo "### Sleeping for 3 seconds before scanning.."
sleep 3
watch -n 1 "
        sudo wlanconfig ath0 list ap
        echo
        echo
        sudo iwlist ath0 scan
"

While iwlist gives more details on the scan result, wlanconfig‘s output is more brief and is more suitable if there are many wireless access points around (that it wouldn’t just fill up the screen). Combining these two, we get the best of both :)

I’ve been using sudo a lot in my scripts, and if you’re wondering won’t sudo be asking for passwords, well, by having this in my /etc/sudoers, the problem is solved;

shakir  ALL=(ALL)      NOPASSWD: ALL


2 Responses to “Script for scanning for available wireless network”

Actually, the minimalist is

# ifconfing ath0 up
# iwlist ath0 scan

We also can use, a passive scanning, using airodump-ng (aircrack-ng suite) or kismet, for better wifi scanning.

That’s really minimal, but as I’m using it for site survey (normally just to see the AP list and their signal strength), I need to use “watch” to refresh the output. “iwlist” gives a more detailed output than “wlanconfig” but as I’m using it with “watch”, chances are that not all scan results will be displayed in the screen if there are many APs in the area. “wlanconfig’s” output is more simplified and can fit in many scan result in one screen. The readability for “wlanconfig’s”output is better than iwlist too.

I reload the driver since if I don’t do that, I’ll probably see APs that was in my previous scan’s result (though I’m no longer in the area) thus giving false result. I still use programs such as kismet but as what I really need for the survey are primarily AP list and their signal strength (the rest are just bonus), these 2 programs fit my need :)


Leave a Reply

Advertisement