Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Is there a way to run a script every time a network interface finishes coming up? Or, is there an equivilent answer to this Debian question on OSX?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

I haven't tried this solution my self - yet, but found this thread: http://superuser.com/questions/201478/run-script-in-os-x-10-6-on-network-connection-like-etc-network-if-up-d/261004#261004

You should consider using crankd, which precisely allows you to run scripts in response to many system events such as network changes, filesystem activity, application launching, etc.

As I couldn't find any sensible documentation, I also wrote a small blog post on getting started using crankd.

share|improve this answer
I checked stackoverflow and the googles, but didn't happen across superuser. Regardless, this is it! Thanks. –  Matt Dec 2 '11 at 2:22

A launchd agent watching /etc/resolv.conf seems to work for me:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \




It might not work if you hardcode your DNS servers in the networking config. With normal DHCP, however, that file is rewritten every time a connection comes up.

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.