es läuft wahrscheinlich darauf hinaus, sich den eigenen DNS-Server samt DDNS-Update-Mechanismen sparen zu können;
wobei ein Tipp:
verwende den DynDNS-Anbieter Deiner Wahl und trage bei Deiner Domain z.B. sowas wie
home CNAME host.dyndns.com
ein; und IPv6 mit dynamischen IPs ist weder vernünftig noch sinnvoll; hier mein Skript welches auf meinem Router läuft, ich verwende als DynDNS Hoster DNShome und habe auch einen IPv6-Tunnel, da mein ISP IPv4only
dieses Skript läuft per cronjob 5 mal pro Stunde (alle 12 Minuten); und es aktualisiert auch die eigene DNS-Zone, kein Hexenwerk;
Bash
#!/bin/bash
LOCKFILE=/var/lock/cronjob-ddns.lock
# the lockfile is not meant to be perfect, it's just in case the
# two cron scripts get run close to each other to keep
# them from stepping on each other's toes.
[ -f $LOCKFILE ] && exit 0
trap "{ rm -f $LOCKFILE ; exit 255; }" EXIT
touch $LOCKFILE
HOST="hostid"
USER="userid"
PWD="passwd"
IP6ADDR="fix"
IP6HOST="hostid"
IP6USER="userid"
IP6PWD="passwd"
LOGFILE=/var/log/.log
TIMEFILE=/var/local/.time
IPADDRFILE=/var/local/.ipaddr
USRAGNT="myDNSsync/1.0"
function infomail( )
{
DATE=$(date +"%a, %d-%m-%Y")
TIME=$(date +"%H:%M:%S (%Z)")
SENDERNAME="Firewall/Router"
SENDEREMAIL="email"
RECIPIENTEMAIL="email"
case $1 in
--change)
MAILSUBJECT="DDNS IP-address changed: $DATE; $TIME"
DATA="Hostname: $2\n\nOld IP-address: $3\nNew IP-address: $4\n\nReply from
DDNS: $5\n"
;;
--error)
MAILSUBJECT="DDNS I/O error: $DATE; $TIME"
DATA="I/O error occured: No reply from DDNS.\n\nLast known IP-address for host
$2: $3\n"
;;
*)
MAILSUBJECT="DDNS Internal error: $DATE; $TIME"
DATA="Internal error occured.\n"
;;
esac
(
echo -e -n "From: \"$SENDERNAME\" <$SENDEREMAIL>\n"
echo -e -n "To: <$RECIPIENTEMAIL>\n"
echo -e -n "Subject: $MAILSUBJECT\n"
echo -e -n "Content-Type: text/plain; charset=\"iso-8859-1\"\n"
echo -e -n "Content-Transfer-Encoding: 7-bit\n\n"
echo -e -n "The following information came from the Router DDNS module.\n\n"
echo -e -n "--[ Data submitted
]-------------------------------------------------------\n\n"
echo -e -n "$DATA\n"
) |/usr/sbin/sendmail -f $SENDEREMAIL $RECIPIENTEMAIL
}
function initializeddns( )
{
ddnsreply=$(curl -A "$USRAGNT" -u "$USER:$PWD" -k -s
"https://www.dnshome.de/dyndns.php?ip=$1&ip6=$IP6ADDR")
if [ "$ddnsreply" ]; then
ddnsreply="${ddnsreply/\<br \/\>/, }"
ddnsreply="${ddnsreply//[$'\t\r\n']}"
fi
if [ "$ddnsreply" ]; then
echo -e -n "$logtime ddns Initializing $HOST: $1, $IP6ADDR; $ddnsreply\n"
>>$LOGFILE
else
echo -e -n "$logtime ddns I/O error [initializing]\n" >>$LOGFILE
return 1
fi
return 0
}
function refreshddns( )
{
ddnsreply=$(curl -A "$USRAGNT" -u "$USER:$PWD" -k -s
"https://www.dnshome.de/dyndns.php?ip=$1")
if [ "$ddnsreply" ]; then
echo -e -n "$logtime ddns Refreshing $HOST: $1; $ddnsreply\n" >>$LOGFILE
else
echo -e -n "$logtime ddns I/O error [refresh]\n" >>$LOGFILE
return 1
fi
return 0
}
function updateddns( )
{
ddnsreply=$(curl -A "$USRAGNT" -u "$USER:$PWD" -k -s
"https://www.dnshome.de/dyndns.php?ip=$1")
if [ "$ddnsreply" ]; then
infomail --change "$HOST" "$2" "$1" "$ddnsreply"
echo -e -n "$logtime ddns Updating $HOST: $2->$1; $ddnsreply\n" >>$LOGFILE
else
infomail --error "$HOST" "$2"
echo -e -n "$logtime ddns I/O error [update]\n" >>$LOGFILE
return 1
fi
return 0
}
function updatednszone( )
{
cat <<EOF |nsupdate -k /etc/ddns.key
server $1
zone ddnshost.example.com
update delete ddnshost.example.com. A
update add ddnshost.example.com. 60 A $1
send
EOF
echo -e -n "$logtime dns Updating ddnshost.example.com: $1\n" >>$LOGFILE
return 0
}
function updateipv6tunnel( )
{
ip6ddnsreply=$(curl -A "$USRAGNT" -u "$IP6USER:$IP6PWD" -k -s
"https://ipv4.tunnelbroker.net/nic/update?hostname=$IP6HOST")
if [ "$ip6ddnsreply" ]; then
echo -e -n "$logtime ipv6 Updating $IP6HOST: $1; $ip6ddnsreply\n" >>$LOGFILE
else
echo -e -n "$logtime ipv6 I/O error [update]\n" >>$LOGFILE
return 1
fi
return 0
}
# get current IP from checkip4.spdyn.de
currentip=$(curl -A "$USRAGNT" -s "http://checkip4.spdyn.de/")
# get old IP from file
oldip=$(cat $IPADDRFILE)
logtime=$(date +"%b %e %T")
if [ "$oldip" == "0.0.0.0" ]; then
initializeddns "$currentip"
if [ "$currentip" ]; then
echo "$currentip" >$IPADDRFILE
fi
else
if [ "$currentip" ]; then
# compare $currentip with $oldip;
# if different, then execute update
# else execute refresh once every
# 6 days 23 hours 48 mins 45 secs
if [ "$currentip" == "$oldip" ]; then
lastupd=$(cat $TIMEFILE)
let nextupd=lastupd+604125
timenow=$(date +"%s")
rslt=-1
if [ $nextupd -lt $timenow ]; then
refreshddns "$oldip"
rslt=$?
fi
else
updateipv6tunnel "$currentip"
updatednszone "$currentip"
updateddns "$currentip" "$oldip"
rslt=$?
if [ $rslt -eq 0 ]; then
echo "$currentip" >$IPADDRFILE
fi
fi
if [ $rslt -eq 0 ]; then
date +"%s" >$TIMEFILE
fi
else
echo -e -n "$logtime ddns I/O error [check]\n" >>$LOGFILE
fi
fi
exit 0
Alles anzeigen