Skip to content

Instantly share code, notes, and snippets.

@soundstorm
Created February 15, 2017 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soundstorm/8717ef29bbc58349e6dd25a4f83a14b7 to your computer and use it in GitHub Desktop.
Save soundstorm/8717ef29bbc58349e6dd25a4f83a14b7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Modified version of http://cacodaemon.de/index.php?id=5
SERVER="dyndns.inwx.com"
USERNAME="hellomynameis"
PASSWORD="secure!!!"
HOSTNAME="example.org"
IPV4=`curl -s http://ipv4.sndstrm.de | grep -o '\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}'`
IPV6=`curl -s http://ipv6.sndstrm.de | grep -o '\([0-9a-fA-F]\{0,4\}\:\)\{4,7\}[0-9a-fA-F]\{0,4\}'`
ABUSE_LOCK_FILE="/tmp/dyndns.abuse"
LAST_IPV4_FILE="/tmp/lastipv4"
LAST_IPV4=`cat $LAST_IPV4_FILE`
LAST_IPV6_FILE="/tmp/lastipv6"
LAST_IPV6=`cat $LAST_IPV6_FILE`
# Lockfile check, lockfile is only used if a abuse result appears
# Delete if abuse marking is solved
if [ -e "$ABUSE_LOCK_FILE" ]; then
echo "Dyndns abuse lockfile exisits: $ABUSE_LOCK_FILE"
exit 1
fi
#end of lockfile check
if [ "$IPV4" != "$LAST_IPV4" ] || [ "$IPV6" != "$LAST_IPV6" ]; then
echo "Current IP: $IPV4 / $IPV6"
RESULT=`curl -s "http://$USERNAME:$PASSWORD@$SERVER/nic/update?hostname=$HOSTNAME&myip=$IPV4&myipv6=$IPV6" | grep -o -E "good|nochg|abuse|badauth|notfqdn|nohost|abuse|dnserr"`
echo "Dyndns.org says: $RESULT!"
else
echo "IP is still the same: $LAST_IPV4 / $LAST_IPV6"
fi
if [ "$RESULT" == "abuse" ]; then
echo "Abuse lock!"
echo "Abuse lock!" > "$ABUSE_LOCK_FILE"
fi
echo "$IPV4" > "$LAST_IPV4_FILE"
echo "$IPV6" > "$LAST_IPV6_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment