Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

up vote 6 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]

-b

share|improve this answer
1  
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

It is possible to do without any third party, see https://github.com/rimar/wifi-location-changer

share|improve this answer
1  
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 at 2:24

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.

Psuedocode:

  • 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

 
discard

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.