Dynamic DNS for NSD

Introduction

nsd-dyndns is a simple script that adds dynamic DNS dunctionality to NSD (authoritative DNS name server).

Requirements

The following is required or suggested:

Installation

Configure your HTTPD

Add the following new virtual host to your /etc/httpd.conf:

     server "update.example.com" {
     	listen on $ext_addr port 80
     	root "/htdocs/dyndns"
     	log access dyndns.log
     }

Create an empty update.html:

# mkdir /var/www/htdocs/dyndns/ 
# touch /var/www/htdocs/dyndns/update.html 

After reloading HTTPD, try to access [http://update.example.com/update.html] The request should show up in /var/www/logs/dyndns.log

Create a zone file for dyn.example.com

Create a new zone file (e.g. at /var/nsd/zones/dyn.example.com.zone) with the following content

$ORIGIN example.com. 
$TTL 300 
@ IN SOA ns1.example.com. admin.example.com. ( 
1524952218 
300 ; refresh 
900 ; retry 
1209600 ; expire 
1800 ; ttl 
) 

; Name servers 
IN NS ns1.example.com. 
IN NS ns1.example.com. 

; A records 
@ IN A 123.123.123.123 
update IN A 123.123.123.123 
dyn IN A 123.123.123.123 

Don't forget to set your own domain names, name servers and ip addresses Furthermore, add this zone file to your /var/nsd/etc/nsd.conf

Configure and Install nsd-dyndns

Configure your router

Configure your router to query the following URL:

http://update.example.com/update.html?qwertzuiop1234567890 

Don't forgert to set your own domain name and to replace the string after “?” with the password you configured in the config file.

What it does

When your router gets a new IP and therefore sends an HTTP request to your server, a similar entry should appear in your /var/www/logs/dyndns.log:

update.example.com 123.123.123.123 - - [29/Apr/2018:20:48:19 +0200] "GET /update.html?qwertzuiop1234567890 HTTP/1.1" 200 6 

When the script is executed e.g. via cron, the following happens:

#dns #code #openbsd #nsd #dyndns