Skip to content

Instantly share code, notes, and snippets.

@imvenj
Created December 11, 2019 02:48
Show Gist options
  • Save imvenj/5ce4dd05bbf3de1cd499d15ea5e94835 to your computer and use it in GitHub Desktop.
Save imvenj/5ce4dd05bbf3de1cd499d15ea5e94835 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set up your username stuff here:
DDNS_USER=YOUR_USERNAME
DDNS_PASS=YOUR_PASS
DDNS_PREFIX=YOUR_DDNS_PREFIX
IP_TMP=/tmp/current_ip
CURL_PATH=/usr/bin/curl
current_ip=$(${CURL_PATH} -s whatismyip.akamai.com)
update_ip() {
echo $current_ip > $IP_TMP
${CURL_PATH} http://${DDNS_USER}:${DDNS_PASS}@members.3322.net/dyndns/update?hostname=${DDNS_PREFIX}.f3322.net > /dev/null 2>&1
}
if [ -f $IP_TMP ];then
saved_ip=$(cat ${IP_TMP})
if [ $saved_ip != $current_ip ];then
update_ip
fi
unset saved_ip
else
update_ip
fi
unset YOUR_USERNAME YOUR_PASS YOUR_DDNS_PREFIX
unset IP_TMP CURL_PATH current_ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment