#!/bin/bash
dnsname="YOURSUBDOMAIN.dns.army"
token="YOURTOKEN"
lastknown="/usr/local/bin/ddns_lastknown"
log="/usr/local/bin/ddns_log"
# get public IPv6
IPV6=$(ip addr list eth0 | grep "global dynamic" | cut -d ' ' -f6 | cut -d/ -f1 | sed -n '1p')
if [ -f $lastknown ]; then
# obtain old IPv6
OLDIPV6=$(sed -n '1p' < $lastknown)
else
# create log file (first execution)
echo -n "$IPV6" > $lastknown
OLDIPV6=""
fi
# send request if necessary
if [ "$OLDIPV6" != "$IPV6" ]; then
wget -q "https://ipv6.dynv6.com/api/update?zone=${dnsname}&token=${token}&ipv6=${IPV6}"
echo `date` "IPV6 update required" > $log
else
echo `date` "IPV6 update not required" > $log
fi