OSX: scan Wi-Fi networks with AirPort command line tool
I recently bought a new router and was going through the basic configuration. Like most routers, the default Wi-Fi channel is set to automatic. This means that when your router boots, it will scan nearby Wi-Fi networks and choose the best channel available. Usually this is your best option, but in my situation my router did not detect other networks and selected a random channel.
But in my room - which is closer to the street - I do detect other networks that may cause interference with my wireless signal. In the search of a wireless network scanner utility, I found out that strangely hidden for the average user, lies a command line airport utility that allows you to view, configure, and troubleshoot your Mac’s wireless connection. This utility is located at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Typing the above command path can be avoided by creating a symbolic link to the command in /user/sbin/ by copying and pasting the command below into a terminal window.
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
This will prompt you for a root password, enter it and hit return. Now you will be able to simply type airport in the terminal window to execute the command.
A few options are available:
macbook:~ Jens$ airport --help
Supported arguments:
-c[<arg>] --channel=[<arg>] Set arbitrary channel on the card
-z --disassociate Disassociate from any network
-I --getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
-s[<arg>] --scan=[<arg>] Perform a wireless broadcast scan.
Will perform a directed scan if the optional <arg> is provided
-x --xml Print info as XML
-P --psk Create PSK from specified pass phrase and SSID.
The following additional arguments must be specified with this command:
--password=<arg> Specify a WPA password
--ssid=<arg> Specify SSID when creating a PSK
-h --help Show this help
But the most interesting option for me was airport --scan, which scans all available wireless networks and shows detailed information about them, including their channel:
macbook:~ Jens$ airport --scan
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
Segers 58:6d:8f:a0:5f:00 -86 36,+1 Y -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)
WiFi1 00:18:02:82:b3:00 -84 6 N BE WEP
WiFi2 00:1c:df:ed:a9:00 -76 6,-1 Y US WEP
WiFi3 06:18:02:82:b3:00 -87 6 N BE NONE
WiFi4 5c:35:3b:01:a3:00 -84 1 Y BE NONE
WiFi5 5c:35:3b:01:a3:00 -83 1 Y BE WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
Segers 58:6d:8f:a0:5f:00 -81 11 Y -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)
With this information you should be able to find out which channel is still available for your network. In my case channel 11 was a good choice since 1 and 6 were used by other networks. Keep in mind that channels close to each other will still overlap and interfere: