Is /etc/resolv.conf changed every time the DHCP lease changes

dnslaunchdNetworkwifi

I'd like to fire an event via launchd whenever my DHCP lease changes the IP on my WiFi interface. My question is similar to what's being asked in this question, which makes me thing I can watch /etc/resolv.conf for changes via a launchd agent.

I differ in my need in that I'd like to fire the event every time the IP changes on an interface, not just when the interface comes up. For the curious, yes, I'm looking to do a simple dynamic DNS updater.

Best Answer

You could write a launchd that monitors the file path of:

/private/var/db/dhcpclient/leases/

If you looking for DHCP changes to an interface.

That db holds all the different interfaces and dhcp changes on them. Something similar to monitoring that file with a launchd here.