Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can Mac OS X be setup to automatically configure its Airport interface with a static IP address when connected to a Wifi network with a certain name, and on all other Wifi networks use DHCP?

Currently I'm using the "Locations" feature of the "Network" section in System Preferences to manually switch between two IP address setups. I have a "my static IP" setup, and a default "DHCP" setup. However this requires entering System Preferences to change the Location drop-down each time when switching locations. Can this be automated?

Preferably this would be done without third-party software.

share|improve this question
up vote 7 down vote accepted

This is not something that can be done simply through the OS.

The aforementioned Locations is one option, along with freeware Airport Location or MarcoPolo or paid Network Location. There is also an AppleScript called WiFiScriptor that could help.

However! you need not go into System Preferences->Network->[Location dropdown] . You can go through the Apple Menu->Location (about 6 options down)->[select the location you want]


share|improve this answer
Thanks for the tip about switching locations from the Apple Menu. Although still manual, that feels at least a little better than going into System Preferences with multiple steps. – Valko Sipuli Jan 8 '11 at 21:03
Also thanks for confirming that is not (currently) possible to do it without third-party software. – Valko Sipuli Jan 8 '11 at 21:09
the Airport Location link seems to point to a spam website now – Nat Jan 5 at 18:49

It is possible to do without any third party, see

share|improve this answer
I would just like to add that in order for this to work, your Location name should be the same as the SSID of the wifi network. The logic of the script is that it checks for a Location with a name similar to the SSID and switches to that. If there's no Location with that name, it defaults to auto/Automatic. – Rystraum Mar 6 '14 at 2:24
Also, I had to log out and log back in before it started working on Yosemite. – djule5 Apr 2 '15 at 12:22

A third-party, non-free solution which would probably work for you is Locations.

As suggested by this answer to a similar, but not identical, question on stackoverflow, you could create a script which runs at a regular interval. launchd will prevent it from running more than once.


  • get saved_wifi value from a file
  • set current_wifi to output of networksetup -getairportnetwork AirPort
  • if saved_wifi == current_wifi, exit
  • else run networksetup -switchtolocation {location} where {location} is the name of the location you want to switch to based on the wifi network found.

There might be a chicken and egg situation here with connecting to local wifi which doesn't provide a DHCP address while you're configured to expect an address from DHCP.


Update: found possible duplicate question which suggests an opensource solution: MarcoPolo

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.