airport – the Little Known Command Line Wireless Utility for Mac

Jan 18, 2007 - 94 Comments

Terminal in Mac OS X Hidden from the casual Mac user is a spiffy command line utility that allows you to view, configure, and troubleshoot your Mac’s wireless connection, entirely from the Terminal of MacOS and Mac OS X. This command has a help file but is otherwise but not much documentation, and judging by the obscure location of the command, Apple probably didn’t think it would be too useful for the average Mac user. But the hidden command line airport tool is very useful indeed, particularly for more advanced Mac users who want to have full control over their wi-fi hardware directly from the command line in Mac OS X.

With that in mind, here is how to access the amazingly useful yet little-known airport tool, and how you can use it for some networking tasks too.

How to Access & Use airport Command Line Tool on Mac OS

In case you were wondering, yes the command line airport tool exists in nearly all versions of Mac OS X, even modern versions that stopped calling wireless networking ‘airport’ and refer to it as Wi-Fi. OK let’s begin.

First, Get Easier Access to airport Wi-Fi Tool

The first thing you’ll want to do is create a symbolic link to the airport command, because it is situated in a very inconvenient location with a deep path, this helps for quick usage. Creating a symbolic link to airport is very easy, in the Terminal type the following:

For MacOS Mojave, Catalina, Big Sur, and newer MacOS releases
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

For Mac OS X High Sierra, Sierra, El Capitan, Mavericks, and earlier
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

The above may be a bit hard to read on some browsers, so alternatively you can use the following (it does the same thing, just split into two commands):

For Mac OS Catalina, Mojave, and newer macOS versions
$ cd /usr/local/bin/
$ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

For Mac OS X High Sierra, Sierra, El Capitan, Mavericks, and earlier
$ cd /usr/sbin
$ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

Note the only difference between modern macOS versions and prior versions is where you will be placing the symbolic link, which is in /usr/local/bin/ versus in /usr/sbin/

Whichever method you go with, the sudo command will prompt you for a root password, enter it and hit return.

Yes, that giant cryptic path through the depths of Mac OS X is where Apple hid the wonderful airport utility, but by running the above command you have just linked that long path to the much shorter ‘airport’ , which is great.

Using the airport Wireless Tool in Mac OS X Command Line

Now that you have quick and easy access to airport with the above symbolic link, you can start using the airport tool.

For starters, you’ll probably find the -I flag and -s flags to be most useful and informative.

For example, with airport -s you will effectively have a wi-fi router stumbler and get a list of available wireless networks complete with their SSID, BSSID hardware address, security encryption type, and channel.

airport -s

airport stumbler wifi router command line Mac

You can also use airport -I at the Terminal prompt, which will return information specific to the current wi-fi connection, looking something like the following:

$ airport -I
commQuality: 75
rawQuality: 59
avgSignalLevel: -40
avgNoiseLevel: -97
linkStatus: ESS
portType: Client
lastTxRate: 11
maxRate: 11
lastAssocStatus: 1
BSSID: 00:06:5b:2a:37:10
SSID: OSXNetwork
Security: none
$

Displayed is detailed information on wireless signal quality, noise, security, and other WiFi network attributes.

The airport command is more powerful than just being able to list information on the current wireless network though, you can actually manually adjust any wi-fi settings, network card settings, troubleshoot networks, change security types used on a connection, capture packets into a pcap file, join and leae networks, disassociate from a wifi network, prioritize routers and networks, see signal strength and interference, adjust wi-fi hardware drivers, and perform a huge variety of network troubleshooting functions too. This is easily one of the most powerful ways to interact with a wireless card on a Mac.

airport wi-fi network command in Mac OS X

While there is no manual page for the airport command, attaching the -h or –help flag to the command to will issue a brief list of flags and explanations of their function. You can also just run ‘airport’ at the Mac OS X command line to get the full help file, shown below:

$ airport
Usage: airport [interface] [verb] [options]

[interface]
If an interface is not specified, airport will use the first AirPort interface on the system.

[verb is one of the following:
prefs If specified with no key value pairs, displays a subset of AirPort preferences for
the specified interface.

Preferences may be configured using key=value syntax. Keys and possible values are specified below.
Boolean settings may be configured using ‘YES’ and ‘NO’.

DisconnectOnLogout (Boolean)
JoinMode (String)
Automatic
Preferred
Ranked
Recent
Strongest
JoinModeFallback (String)
Prompt
JoinOpen
KeepLooking
DoNothing
RememberRecentNetworks (Boolean)
RequireAdmin (Boolean)
RequireAdminIBSS (Boolean)
RequireAdminNetworkChange (Boolean)
RequireAdminPowerToggle (Boolean)
WoWEnabled (Boolean)

logger Monitor the driver’s logging facility.

sniff If a channel number is specified, airportd will attempt to configure the interface
to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.
Requires super user privileges.

debug Enable debug logging. A debug log setting may be enabled by prefixing it with a ‘+’, and disabled
by prefixing it with a ‘-‘.

AirPort Userland Debug Flags
DriverDiscovery
DriverEvent
Info
SystemConfiguration
UserEvent
PreferredNetworks
AutoJoin
IPC
Scan
802.1x
Assoc
Keychain
RSNAuth
WoW
P2P
Roam
BTCoex
AllUserland – Enable/Disable all userland debug flags

AirPort Driver Common Flags
DriverInfo
DriverError
DriverWPA
DriverScan
AllDriver – Enable/Disable all driver debug flags

AirPort Driver Vendor Flags
VendorAssoc
VendorConnection
AllVendor – Enable/Disable all vendor debug flags

AirPort Global Flags
LogFile – Save all AirPort logs to /var/log/wifi.log

[options] is one of the following:
No options currently defined.

Examples:

Configuring preferences (requires admin privileges)
sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES

Sniffing on channel 1:
airport en1 sniff 1

LEGACY COMMANDS:
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

As you can see, there is an abundance of options to interact with wireless networks by using the airport utility in Mac OS X. Advanced Mac users should really get a kick out of this one, as it’s extremely powerful, and wildly useful.

You can also do some pretty interesting things with airport. For a few examples, you can test wireless signal strength live from the command line with airport. Another example will list available wi-fi routers by name only that are nearby, sorted by signal strength (thanks to @jacobiun for this) but omitting BSSID and other data:

airport -s | tail -n +1 | sed 's/ [a-z0-9][a-z0-9]:/,&:/g' | sed 's/ -/, -/g' | cut -d ',' -f1,3 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' | grep -v "SSID" | sed 's/ /,/g' | cut -d ',' -f1,2 | sort -t ',' -k 2

The next time you’re working on any wi-fi related task or wireless networking in general, remember the awesome airport tool.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

94 Comments

» Comments RSS Feed

  1. George Milnes II says:

    I don’t know what I’m doing wrong, but I get this message:

    ln: usr/local/bin/airport: No such file or directory

    ??

    Any insight appreciated

    • Paul says:

      Make sure you enter the syntax exactly as written. Looks like you’re missing a / in front of /usr when running the command

      The first command simply links (like an alias) the buried airport command to /usr/local/bin/airport

      sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

      This allows you to then simply type ‘airport’ to run the command

  2. George Milnes II says:

    I don’t know what I’m doing wrong, but I get

    ln: /usr/local/bin/airport: No such file or directory

    ??

  3. Benji says:

    I’m trying to do this but I get this error:

    “(user) is not in the sudoers file. This incident will be reported.”

    I’m logged into my Mac as the admin, so this should not be happening. (Assuming my password is the computer’s password, not my Apple ID password.)

    macOS 10.14.6 latest updates…did some security update mess something up here?

  4. Mabingo says:

    sudo airport en1 sniff 8
    Capturing 802.11 frames on en1.
    Segmentation fault: 11

    I’m Chinese and I don’t speak English very well. My problem is that I can’t grab the packet as above, and I didn’t give this error message back for a long time.

    thanks。

  5. Pabo says:

    This airport command is so great, I use it all the time in the Terminal of MacOS Mojave for most networking tasks. Thanks.

  6. pearls says:

    how to connect wpa2-enterprise security wlan using airport utility

  7. Jason says:

    what does it mean to disassociate (-z) from a network?

    i can’t quite find enough explanations on this

    • Pabo says:

      Disassociating from a network disconnects from that network and loses any associations to it, but it does not turn off general wi-fi. Hope that makes sense!

  8. Tom says:

    Can someone figure out how to do this on Sierra.

    • Paul says:

      The airport command continues to work in MacOS and Sierra, if you are having difficulties with the soft link you can also add an alias to the .bash_profile like so:

      alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'

    • J0scer says:

      This is macOS System Integrity Protection (SIP) which prevents even root from changing things in /System, /usr, /bin, /sbin and pre-installed Apps.

      An exception in /usr is that /usr/local can be written.

      so try this

      sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

      this works fine in Sierra

  9. zebrum says:

    On El Capitan the path is /usr/local/bin/airport

  10. longkeyy says:

    sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

  11. PavelPage says:

    I did it in the two ways and i couldn’t:

    ln: ./airport: Operation not permitted

    i´ve tried to do it with the superuser and dose not works =/

    someone can help?

    thanks

    • kevin says:

      Hi,Did you use OSX 10.11?
      See”https://en.wikipedia.org/wiki/System_Integrity_Protection”,you can not write /usr/ ,but not /usr/local.
      So,try this:

      sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/sbin/airport

  12. Eliyah says:

    instead of linking the file into /usr/sbin like you suggested, you can also add the following line to your .profile (% nano .profile):
    alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"

  13. mioico says:

    Wonder if there’s any counter part on IOS(8 meanwhile).
    Any ideas?

    Best

  14. Alan says:

    Does anyone know a command to remove a client wireless from my network? For example an iPhone from somebody that use my network wireless. Thanks for help

  15. Mac OS X says:

    […] Networking is pretty straightforward, and has its own command line utility, airport. […]

  16. […] long hidden airport command line utility buried deep in Mac OS X can be used to scan for and find available wireless […]

  17. ed says:

    does anyone know a way to lock my wifi card of my macbook air to use (a) only ?

    on my PC I can change the driver settings of my wifi card to use 5.2ghz only and i would love to be able to the same on my mac.

    I want to do this because at my work there are multiple repeaters.

  18. JohnAnthony says:

    Awesome tipp :)

  19. nono says:

    Note that at least on 10.6, many airport infos are available when clicking on regular menubar airport icon with “Alt” key pressed.
    One of the many eastern egg embedded by Apple through ages!

  20. […] OS X comes with a nifty little known command line wireless utility. To enable easy access to it, run the following to put it in the command line’s search path: […]

  21. WifiAdminGuy says:

    This is freakin’ awesome. Thanks for finding and posting this. I wish I had known about this sooner.

  22. […] osxdaily hat auch noch diese Zeile hier zum Besten gegeben, um einen einfacheren Aufruf zu gewährleisten: sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport Danach kennt das Terminal ein airport-Kommando =) […]

  23. […] command) that would let me see which AP I had associated with. After some digging around I found this webpage that told me that there is indeed a command (very well hidden) right there in the OS. For some […]

  24. Mactard Shortbus says:

    Once again, Mac’s needlessly restrictive and retarded ‘Think Different’ meets up with BSD’s obsessive ‘stability’ and buries the command to print wireless info behind, what, seven directories? Why is ifconfig in $PATH but ‘airport’ (seriously? seriously? does the wireless make the computer fly? WTF?) is not? Why is ssh in $PATH but airport isn’t? Why is it that people smart enough to design with global menus, autohiding docks, multi-touchpads and the best laptop shell (the case, not the UI) ever don’t realize that wireless access is almost a necessity for enterprise and personal computer use in this day and age and that, silly me, I thought that it would be ‘faster’ to use a terminal than GUI to learn my wife’s work machine’s MAC address so we could fix the damn network.

    Of course, I realize the answer to my question is “because designers make terrible engineers and engineers make even worse designers” but I, like, thought they ‘Think Different’ out in Cupertino.

  25. Dilli R. Maharjan says:

    Great Tips,
    Thanks man

  26. […] Kriesel benutzt. Um an die W-Lan Daten zu kommen habe ich (da ich ein Macbook benutze) den Befehl „airport -s“ mit dem ProcessBuilder verwendet weil Java diese Funktion leider nicht zur Verfügung stellt. […]

  27. […] else is really valuable. Here’s a way you can do this through the command line using the airport wireless tool we’ve discussed in the […]

  28. Jan van Haarst says:

    Since Snow Leopard you need to use the networksetup command to connect to a wireless network from the command line.
    Like this :
    sudo networksetup -setairportnetwork en1 SSID PASSWORD

    • Brian says:

      THANK YOU!!!

      I’ve been pulling my hair out trying to figure out why ‘sudo airport -associate’ or any of the other similar commands haven’t been working for me, and haven’t been able to find Snow Leopard stuff anywhere else.

    • Mike says:

      I’m using lion and couldn’t get this or the -A to work, any ideas?

  29. john says:

    Does anybody know how to connect to a specific ssid with the airport command ? It seems that in snow leopard the parameter “-A –associate” is no longer available…what else can be used to connect to a certain ssid by command line?? thks

  30. Jonathan says:

    Just in case nobody know, but, most of the info you can get with this little command line util is available by simply holding down the ALT key on your keyboard before you click on the little wifi symbol in the top screen bar (on the right).

    By pressing ALT, it will revel a lot more information that the signal level, pretty much the same thing you get with #airport -I.

    There are lots of stuff like that hidden away in OSX. The principle as I see it is that most people don’t need to know that, so they hide it, but for power user, it’s usually as easy as holding down a key (usually ALT) before clicking on a lot of things to revel more advanced option.

    I guess, it would be nice to have an advanced options on/off switch somewhere in the system preferences for people who want to see all the available options.

    There you go!

  31. […] rate 2MB, en windows hay que modificar el valor en las propiedades del adaptador y en os x? airport – the Little Known Command Line Wireless Utility – OS X Daily Juegue 8) […]

  32. ww says:

    I’m having the same problem as Ryan (above), i can’t seem to get it to connect to one of multiple same-SSIDed routers using the BSSID. Anyone figure this out?

  33. […] airport – the Little Known Command Line Wireless Utility […]

  34. sony battery says:

    This tip has ended hours of pulling my hair out. I’d been having trouble with my Mac mini computer automatically joining random wireless networks rather than the *one* network I’d ever want it to join … and this is despite using Network Preferences to configure Airport to join only preferred networks by default; to ask before joining an open network; and to require an admin password to change wireless networks.

  35. Sweatermeat says:

    Another good command line:

    Did you ever fart so hard you ended up in another zip code?

  36. Chris says:

    Is there any way to turn up the roaming aggressiveness of the airport card? We have many APs here, but the airport card doesn’t always connect to the closest one, especially after moving around the office…

  37. mystergag says:

    Nice CLI command….thanks.
    But we are protected by WPA2-Enterprise (so Radius in the back) So we have DOT1.x user and pass configure in the GUI for our WIFI connection.

    Is there a way to pass those informations by giving specifics arguments to the command airport.

  38. zaphod says:

    you can hold down the option key when clicking on the airport menu to get some of the more useful troubleshooting info.

  39. […] the Airport, called “airport”. Only its buried pretty deep in the system. Visit this article to find out more. I’ll show you how to add this to your PATH to make sure its always available. We can use […]

  40. jim says:

    Sorry for the 2nd post— more info – I CAN change and add associations to wireless networks on ppc and intel platform as long as they are not encrypted. Our change is going from unencrypted closed network to a wpa2 closed network. If I can make this work I can send remote commands with the security software we use on the Macs.

  41. jim says:

    I can’t make this work on PPC computers running 10.4.11 only on intel 10.4.11 – here is the command I have been using
    airport -A –associate= –password=

    This is important to me because my network manager is changing our wireless security on 15 campuses and I need to make all the wireless macs change over…about 1000 G4 iBooks. Any ideas as to why the intel and ppc 10.4 computers act differently with the same command?

  42. […] is not readily accessible. We make it that way with the following command in Terminal (found here): sudo ln -s […]

  43. Flüge Bangkok says:

    Thank you very much for the useful tips
    You have really saved my time .
    Since I have bought my new macbook, I have had a lot of difficulties to configure my wireless network settings.
    My laptop was automatically joining my neighbour’s network rather than the network I’d ever want it to join.
    That was bothering for me and I intended to bring it bag to the shop, but the laptop has a very nice design, That’s why I haven’t done it.

  44. í•œìŠ¤ì˜ ìƒê°…

    airport – the Little Known Command Line Wireless Utility ì—ì–´í¬íŠ¸ ìƒíƒœë¥¼ 커맨드ë¼ì¸ìœ¼ë¡œ 확ì¸í•´ì•¼ í•  때……

  45. Mark says:

    Does anyone know if there is a command switch to tell the NIC to run 20/40mhz? Network Utility displays 130 and that means the NIC is not set to 20/40. I wish there were a configuration utility to set these parameters like in Windoz. When running Bootcamp, I have no problem with wireless N settings and attain 270+ speeds. It is only a problem in OSX, which is, of course, why I have my wonderful MacBook Pro. I love my Mac, but I want more speed, and need my DIR-655 functionality.

  46. @DOH says:

    “I have an idea..
    I have an idea.. You can use an OS that doesn’t require you to and open command line utilities and terminals
    and write SCRIPTS just to accomplish the simpleist everyday tasks!!”

    You are implying OSX requires one to use terminal to perform some of the operations listed here.

    Well OSX doesn’t require this d-bag.

  47. the obvious says:

    I have an idea..
    I have an idea.. You can use an OS that doesn’t require you to and open command line utilities and terminals
    and write SCRIPTS just to accomplish the simpleist everyday tasks!!

    DOH

  48. Gregory says:

    In response to Jason’s comment:
    “Unfortunately, I can’t seem to figure out how to connect to SSIDs that are not broadcasted. Anyone have an idea?”

    Try this syntax instead:

    $ sudo airport -A –ssid=ESSID –password=PASSWORD

    it worked for me.

    For spoofing mac you could try (tested on OS X 10.5.6):

    $ airport -z #optionally disconnect from network to hide your mac change
    $ sudo ifconfig en1 ether AA:BB:CC:DD:EE:FF #this can only be done when the interface is up (or at least from my experience)
    $ sudo airport -A –ssid=ESSID –password=PASSWORD #reconnect to network.

    Now the airport GUI will tell you your original mac address still, but when you are connected if you check output from ifconfig:

    $ ifconfig en1 ether|grep ether
    ether AA:BB:CC:DD:EE:FF

    similarly, if you have admin access to the router you can check the connected devices there and see your mac should have changed.

  49. […] Re: Gestione airport da terminale On 15 Mag, 23:56, Massimo <rana…@gmail.com> wrote: Ti posto un sito di interesse https://osxdaily.com/2007/01/18/airpo…eless-utility/ ciao « aggiungere capitoli | Gli utenti windows » […]

  50. […] Handy little wireless command line command. […]

  51. anonymous says:

    macbook:Resources root# airport -h
    airport AirPort v.522.4 (522.4.0)
    Supported arguments:
    -z –disassociate Disassociate from any network
    -i[] –ibss=[] Create IBSS
    -x –xml Print info as XML
    -s[] –scan=[] Perform a wireless broadcast scan.
    Will perform a directed scan if the optional is provided
    -r –repeats= Repeat the command the specified number of times
    -A[] –associate=[] Associate to network.
    Will prompt for network name if arg is not specified
    and if necessary, for a password if the network is using WEP or WPA.
    The following additional arguments may be specified with this command:
    –bssid= Specify BSSID to associate with
    –password= Specify a WEP key or WPA password
    -I –getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
    -P –psk= Create PSK from specified pass phrase and SSID.
    The following additional arguments must be specified with this command:
    –ssid= Specify SSID when creating a PSK
    -c[] –channel=[] Set arbitrary channel on the card
    -h –help Show this help
    macbook:Resources root#

  52. […]   My MacBook usually didn’t feel like reconnecting to my AirPort after waking up from sleep mode. I’ve finally been able to solve that problem usingthe aiport command line utility and SleepWatcher. Simply installed SleepWatcher, and created the following little script in~/.wakeup: […]

  53. Jason says:

    You can add some code to automatically connect you the the SSID you like.

    $sudo airport -A –associate=SSID –password=PASSWORD

    Unfortunately, I can’t seem to figure out how to connect to SSIDs that are not broadcasted. Anyone have an idea?

  54. 3cr0wn says:

    if you are just trying to disconnect your connection

    $airport -z

    to scan for available networks

    $airport -s

    to join you need root access

    $sudo airport -A

    you will then be prompted for the SSID you’d like to join.

    Great find, thanks for sharing.

  55. bm says:

    I’m having the same problem as Ryan (above), i can’t seem to get it to connect to one of multiple same-SSIDed routers using the BSSID. Anyone figure this out?

    10.4

  56. […] The Little Known Command Line Wireless Utility […]

  57. […] via: airport – the Little Known Command Line Wireless Utility – OS X Daily Search […]

  58. […] Next I remembered a very useful post about How to get the wireless signal strenght from you airport and I decided to put togheter my (very small) knowledges of RubyCocoa to create a script that make your mac to work as an hot spot detector. […]

  59. Weja says:

    Guys I really need your help ASAP :( I have this huge problem in turning my AirPort on. I cant select the Airport’s checkbox in my network port configurations and I dont know why??? I can select and deselect the rest of the ports (bluetooth, internal modem, built in ethernet, etc) but NOT the AirPort!!!!
    HELP MEEEEEEEEEEEEE

    Thanks

  60. walter says:

    I’m looking for a way to automate the wireless configurations of hundreds of laptops in my school.

    Can anyone point me to a solution?

    I’m configuring the wireless using peap with mschap v2 and a certificate, all the laptops are macbooks osx 10.4

    Thanks.

  61. Ricardo says:

    I have do this implementation in python to automatically reconnect to my wireless if disconnected:

    import os
    import time
    import logging

    CHECK_PERIOD_IN_SECONDS = 60
    TEMPFILE = “connection-info.txt”
    KEYWORD = “MyPlace”
    LOGFILE = “airport-reconnect.log”

    def is_connected():
    # Generate connection info
    os.system(“/usr/sbin/airport -I >” + TEMPFILE)
    # Read connection info
    f = open(TEMPFILE, “r”)
    data = f.read()
    f.close()
    # Check
    return KEYWORD in data

    def connect():
    os.system(“/usr/sbin/airport -a”)
    logging.info(“Re-connected.”)

    if __name__ == “__main__”:

    # Logger
    try: os.remove(LOGFILE)
    except: pass
    logging.basicConfig(level=logging.DEBUG,
    format=’%(asctime)s %(levelname)-8s %(message)s’,
    filename=LOGFILE,
    filemode=’w’)

    # Loop
    while True:
    if not is_connected():
    connect()
    time.sleep(CHECK_PERIOD_IN_SECONDS)

  62. […] As a temporary solution, I found how to re-connect from a command line, thanks to the blog article “airport – the Little Known Command Line Wireless Utility”. I’ve created the file reconnect.sh and run it when required: […]

  63. vchoi says:

    Very nice command. Saved my day as I need to troubleshoot problems in my wireless network.

  64. Ryan says:

    Someone please help me. I have tried to use this command to associate via BSSID and cannot get it to work. So far as I can tell, all the other commands work fine. I have several routers that have the same SSID and I need to be able to specify which one to connect to. Can someone help me?

  65. @David

    I’ve run into similar problems before with some networks that seem to have a strict policy on idling. To circumvent this, try constantly pinging a server (either on the network or outside). To do this, open your Terminal (spotlight for Terminal) and type the following:

    ping google.com

    instead of google.com you can use your LAN router or whatever other IP (10.1.1.1). Just let that run in the background while you’re doing things, and your connection should stay alive since small amounts of data are constantly being sent.

    Hope that helps,

    Paul

    • PavelPage says:

      Thanks!

      It works well

      =)

    • PavelPage says:

      Hello Paul

      I would like to know if you can help me with this: I’ve been trying to hack a wp2, and I’ve been using aircrack and reaver, but using Macintosh it’s kind complicate. Do you have a manual or instructions to do it in Macintosh, just the basic -monitor mode, scan,…-. Or is just not possible? I believe that Macintosh it’s a very powerful tool to not be able to do it.

      Thanks again.

  66. David says:

    Is there a way to use this utility to maintain a wireless connection? At work, I use my MacBook Pro with a wireless network (a building full of PC’s) that, when idle for very long, breaks the wireless connection, requiring logging on again. I have been unable to find a “stay connected” utilitiy for wireless like we used to have with modems.

    Thanks

  67. Marco says:

    Hi man!
    This command is very useful, but I have a question:
    airport -I gives info about signal strenght with the line

    avgSignalLevel: -40

    I think this value is in dB.

    When you type airport -s, you have the list of all networks avaiable, but which is the parameter which identifies the signal strenght? I think it could be

    Sig 56

    But it is in Watt or what?

    • WifiAdminGuy says:

      Signal Strength is the “RSSI” field. It is in units of dB. Since we’re in power, when you double the signal strength you will see a 3 dB increase. Same with average signal level.

      (truth: I’m guessing this is dB because all the linux driver wifi code I have seen reports that all major cards report in dB)

  68. tuco says:

    How do you spoof your MAC address on a PowerBook wireless card?

    $ ifconfig lladdr xx:xx:xx:xx:xx

    works on /dev/en0 but no luck on /dev/en1.

  69. anon says:

    Still works in Leo! (That’s ‘cool’ for Leopard, Googlebots)

  70. AirPorter says:

    To actually turn airport off, you simply take the AirPort network interface down like so:

    sudo ifconfig en1 down

  71. Mifilte says:

    airport -z unjoins all networks

  72. anon says:

    Anyone know how to use this command line util to turn airport off?

  73. KB says:

    This tip has ended hours of pulling my hair out. I’d been having trouble with my Mac mini computer automatically joining random wireless networks rather than the *one* network I’d ever want it to join … and this is despite using Network Preferences to configure Airport to join only preferred networks by default; to ask before joining an open network; and to require an admin password to change wireless networks.

    I wrote a script which runs “airport -I” to notice when I’m not connected to my desired network and then to run airport –associate to rejoin. I’m using cron to run this script every few minutes, and my logs show this fixing things several times a day so far.

    This also allowed me to add a StartupItem so that I can have my mini (which runs my web site, etc.) join the correct network on startup before anyone even logs in. Before I found this tip, I couldn’t find a way to get my mini to join any wireless network until I logged in.

    • gurgan says:

      If you could please share that script for having airport connect pre-login, that would be awesome. I need airport to be connected at login so I can access network accounts. Silly Apple.

  74. nate says:

    There’s documentation available, just type:

    $airport –help

    Its not too informative, but there’s some info there.

  75. Here’s another vote for “holy moly”! Now I’ll have to go dig through the system for any and all hidden executable binaries. Who knows what else is hidden?!

  76. Alpharetta says:

    HOLY MOLY BEST EVER!!

  77. Shlomo says:

    Awesome! Thanks for the cool util

  78. anon says:

    That’s a great tip – nice find, OSXDaily.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site