Skip to content

Instantly share code, notes, and snippets.

@oliveratgithub
Created November 5, 2015 14:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save oliveratgithub/a50a3d6bcb1e030ed06e to your computer and use it in GitHub Desktop.
Save oliveratgithub/a50a3d6bcb1e030ed06e to your computer and use it in GitHub Desktop.
Automatic Dynamics DNS updater using HTTP API calls, prepared for TwoDNS.de / Two-DNS.de (works with any other DDNS Service, allowing IP updates via HTTP API calls)
#!/bin/sh
log="ddns_updater.log.txt"
my_ext_ip=$(curl -sS http://icanhazip.com)
echo "\n\n\n===== \
\n$(date -u) \
\nUpdating IP to: $my_ext_ip \n" >> $log
curl -isSX PUT \
-u "mail@host.tld:api_token" \
-H "Content-Type: application/json" \
--data '{"ip_address":"'$my_ext_ip'", "activate_wildcard": "false"}' \
https://api.twodns.de/hosts/host.dynvpn.de >> $log
exit
@gerlof85
Copy link

Your suggestion is indeed very useful, thanks! Currently I have the script scheduled via Cron to fire it up periodically. To run it via nohup there would need to be some sort of loop and a waiting mechanism between the actions. And if I'm understanding it correctly if any changes to the script were to be made, the current nohup instance must be stopped and a new one needs to be started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment