When I am at work, I mount a number of shared drives to use during the day. At home, I mount drives on my home network for home use. Is there a way that I can automatically mount the correct drives based on the network I am connected to? Ideally I would do this based on IP address, as I connect via Ethernet cable at work.

Is it necessary to use AppleScript or a shell script? I have tools like Hazel and Keyboard Maestro at my disposal.

Thank you.

set homeip to "Enter Your Home IP Here"
set homedrive to "afp://PlzUpvoteThis.Answer"
set workdrive to "smb://FeelFreeToEdit.This"

set myIP to (do shell script "curl ipinfo.io/ip") // Gets ip

if myIP is homeip then // Checks if your ip matches your home ip
    do shell script "open " & homedrive
    do shell script "open " & workdrive
end if

I would suggest simply saving aliases of each mounted network share. Assuming that you have allowed Keychain to store your credentials for these shares, they will mount automatically when you open the alias in the future.

I personally use the following strategy. I add my ~/Library/Favorites folder to my Finder sidebar and my Dock. Then, I place aliases of each of my file shares (and other network connections like SSH, FTP, RDP, etc.) in that Favorites folder. In this way I have two-click access to any resource on my network(s). I name these aliases using a consistent convention like "SMB - Server 1 - Share A", "SMB - Server 1 - Share A", "SMB - Server 1 - Share B", "AFP - Server 2 - Share C", "VNC - user@example.com", etc. In this way the connections are sorted and easy to find in my Favorites folder.

You could prefix your aliases with "Home-" and "Work-" so they all sort together as well.


A few years ago I have used ControlPlane, but now I no longer use it. You need to test yourself whether it supports the latest OS X.

supports a number of evidence sources:

  • Current Audio Output destination (speakers or headphones)
  • Connected Power Adapter (based on serial number of the adapter)
  • Bonjour
  • CoreLocation, OS X’s location services for locating you
  • Current IP address
  • e.g

and you can perform many Actions

  • Change your default browser
  • Change your iChat status
  • Play an iTunes playlist
  • Lock or Unlock your keychain
  • Change IMAP server in Mail.app
  • Mount/Unmount external and network drives
  • Change OS X’s built in Network Location in order to change network preferences.
  • and so many others

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .