first commit

This commit is contained in:
Michael Clemens 2018-04-29 20:39:07 +02:00
commit 4f05d03713
3 changed files with 24 additions and 0 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# nsd-dyndns

7
dyndns.conf-dist Normal file
View File

@ -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"

16
dyndns.sh Executable file
View File

@ -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