1) Copy this script to /var/root/dyndns.sh
#!/bin/sh
if [ ${ip=$(curl -s ifconfig.me)} != ""$(cat ~/.dyndns.ip) ]; then
curl "http://USERNAME:[email protected]/nic/update?hostname=HOSTNAME&myip=$ip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
fi
echo $ip > ~/.dyndns.ip
2) Edit USERNAME, PASSWORD and HOSTNAME for your DynDNS account
3) Check it runs /var/root/dyndns.sh
4) Copy this script to /Library/LaunchDaemons/dyndns.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>dyndns</string>
<key>ProgramArguments</key>
<array>
<string>/var/root/dyndns.sh</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>
5) Run launchctl load dyndns.plist
6) Run launchctl start dyndns
Notes:
– You can adjust the interval so that the script runs more frequently than every hour by modifying the 3600 seconds
– If you want to update multiple hostnames you can put them in a comma separated list
– For more information on DynDNS see:
http://dyn.com/support/developers/api/perform-update/