commit 4f05d037130b0ecf83c0b0d43379f935a9ab08fe Author: Michael Clemens Date: Sun Apr 29 20:39:07 2018 +0200 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..d56cbc6 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# nsd-dyndns diff --git a/dyndns.conf-dist b/dyndns.conf-dist new file mode 100644 index 0000000..b7b01a3 --- /dev/null +++ b/dyndns.conf-dist @@ -0,0 +1,7 @@ +PASS="qwertzuiop1234567890" +LOG=/var/www/logs/dyndns.log +LAST_IP="none" +LAST_IP_FILE=/tmp/last_dyndns_ip.txt +TIMESTAMP=$(date +%s) +ZONEFILE=/var/nsd/zones/dyndns.org.zone +SUBDOMAIN="blah" diff --git a/dyndns.sh b/dyndns.sh new file mode 100755 index 0000000..6af24f3 --- /dev/null +++ b/dyndns.sh @@ -0,0 +1,16 @@ +#!/usr/local/bin/bash + +. /etc/dyndns.conf + +REQ_IP=$(grep ${PASS} ${LOG} | tail -1 | awk '{print $2}') + +if [ -f $LAST_IP_FILE ]; then + LAST_IP=$(cat $LAST_IP_FILE) +fi + +if [[ $LAST_IP != $REQ_IP ]]; then + cat $ZONEFILE | sed "4s/.*/${TIMESTAMP}/" | sed "s/^${SUBDOMAIN}.*/${SUBDOMAIN} IN A ${REQ_IP}/" > $ZONEFILE + /etc/rc.d/nsd reload + echo $REQ_IP > $LAST_IP_FILE + echo "update" +fi