Since my servers access are additionally secured by allowing access only from a specific hostname, it is necessary to update my dynamic dns (I am using afraid.org which is working flawless and is cheap too) whenever my network connection changes (and apparently if other system configuration settings are changed, which also might involve VPNs, Proxies or non-network related settings).
It might also be used to execute an external script, but in my case it is sufficient to do a curl request to a specific URL from the my laptop.
--BEGIN org.afraid.freedns.plist-- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.afraid.freedns</string> <key>Program</key> <string>/usr/bin/curl</string> <key>ProgramArguments</key> <array> <string>curl</string> <string>-s</string> <string>https://freedns.afraid.org/dynamic/update.php?YOURKEY</string> </array> <key>WatchPaths</key> <array> <string>/Library/Preferences/SystemConfiguration</string> </array> </dict> </plist> --END org.afraid.freedns.plist--
Save this as
Library/LaunchAgents/com.afraid.dyndns.updater.plist and you’re good to go.