Coffee shops, malls, hotels, and now even cars are being made with built-in wireless hotspot features. Wi-Fi access is everywhere! And while it's been made relatively easy enough to connect to access points for consumers, sysadmins face a different challenge when having to manage wireless settings, especially on mobile devices.
For those leveraging mobile device management (MDM) platforms to push settings, this is a non-issue, but if the cost of these suites remains prohibitive or connectivity is spotty, the following Terminal commands can be used to manage Wi-Fi settings in OS X. They can even be incorporated into a script and deployed to remote end users.
Before moving forward with the various networksetup-based commands, please note that as of OS X 10.8, the AirPort Terminal command, which is what drives some of the changes made to Apple's AirPort wireless connections, has been hidden within the OS and must be referenced directly each time the command is run. To side-step this, run the command below first, which will create a symbolic link to the AirPort command itself so that it may be referenced each time without having to enter a long string of commands each time.
- Create a symlink to the AirPort command in Terminal
ln -s /System/Library/PrivateFrameworks/Apple80211.framework/ Versions/Current/Resources/airport /Usr/bin/airport
- Network connections list
- Enable or Disable Wi-Fi
networksetup -setairportpower en0 on (or off)
- Secure Wi-Fi Settings
airport prefs RequireAdminIBSS=YES RequireAdminPowerToggle=YES RequireAdminNetworkChange=YES
RequireAdminsIBSS=yes (or no) | Restricts creation of ad-hoc networks to admins.
RequireAdminPowerToggle=yes (or no) | Restricts power on/off of Wi-Fi to admins.
RequireAdminNetworkChange=yes (or no) | Restricts network changes to admins.
- View available Wi-Fi networks
- Join Wi-Fi network
networksetup -setairportnetwork en0 SSID_OF_WIRELESS_NETWORK WIRELESS_NETWORK_PASSPHRASE
- Create a Wi-Fi network profile
networksetup -addpreferredwirelessnetworkatindex en0 SSID_OF_NETWORK INDEX_NUMBER SECURITY_OF_WIRELESS_NETWORK WIRELESS_NETWORK_PASSPHRASE
SSID_OF_NETWORK | SSID of the network you wish to join/create a profile of.
INDEX_NUMBER | Numerical value to assigns a position in the list of preferred wireless networks. A value of "0" adds to the network to the top of the list.
SECURITY_OF_WIRELESS_NETWORK | Wireless network security type (ex.) WPA2.
WIRELESS_NETWORK_PASSPHRASE | Password or passphrase used to authenticate the password-protected network.
- Delete a Wi-Fi network profile
networksetup -removepreferredwirelessnetwork en0 SSID_OF_NETWORK
- Remove all stored Wi-Fi network profiles
networksetup -removeallpreferredwirelessnetworks en0
Though managing wireless network settings may seem trivial to some, in densely packed office buildings with dozens of Wi-Fi networks broadcasting their signals, data security is a big concern. Configuring wireless endpoints so that they're properly secured against eavesdropping from unauthorized networks is just one way in which network administrators work with system administrators to ensure that secured wireless access is granted through trusted networks and managed accordingly.
How do you manage Wi-Fi for Macs in your organization? Share your experience in the discussion thread below.
- Pro tip: How to enable SSH via Terminal
- Pro tip: How to troubleshoot Wi-Fi issues in OS X Yosemite
- CNET: How to adjust network settings in OS X via the command line
- ZDNet: With OS X 10.10.4, Apple fixes networking issues by going back to the well
Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 19 years of experience and multiple certifications from several vendors, including Apple and CompTIA.