Little PHP script to 'simulate' a dyndns.org like Dynamic DNS service hosted on your own BIND DNS resolver. Works for example for UniFi Product line of gateways.
works for me :). Feel free to debug and adjust if needed.
apt install bind9 bind9-utils dnsutils
-
dnssec-keygen -a HMAC-SHA512 -b 512 -n USER -r /dev/urandom meinkey
- Copy secret in
*.key
file
- Create
/var/lib/bind/keys.conf
withchmod 600
and contents:key "ddns-key" { algorithm "HMAC-SHA512"; secret "COPIED SECRET FROM ABOVE"; };
- Append
include "/var/lib/bind/keys.conf";
tonamed.conf
- Define zone file in
named.conf.local
zone "dyn.example.com" { type master; file "/var/lib/bind/db.dyn.example.com"; allow-update { key ddns-key; }; };
- Create basic zone file
cp /etc/bind/db.empty /var/lib/bind/db.dyn.example.com
- Adjust SOA and NS values to your needs.
- Restart BIND
- Set NS and GLUE Records at your primary DNS provider to point
dyn.example.com
to your BIND server
All paths are suited for an ISPCOnfig installation
-
Copy update.php to
/var/www/example.com/web/nic
-
Copy config.php and functions.php to
/var/www/example.com/private
-
Adjust Variables in
config.php
-
Create
.htpasswd
htpasswd -c ../../private/.htpasswd ddns
-
Create
.htaccess
Rewrites update.php to be served via /nic/update without file extension. (Needed for UniFi)
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] <Files .htaccess> Order allow,deny Deny from all </Files> <FilesMatch "update\.php$"> AuthType Basic AuthName DynDNS AuthUserFile "/var/www/example.com/private/.htpasswd" Require user ddns </FilesMatch>