Table of Contents
Dynamic DNS
This project is a PHP script endpoint for Dynamic DNS updates using ddclient or compatible clients.
This depends on MySQL and Power DNS.
It can be used for hosts at home running Nextcloud, for example.
Database
Set up your domain in Power DNS and add this new database table for ddclient authentication.
ddclient.sql
USE pdns; CREATE TABLE ddclient ( id INT AUTO_INCREMENT, host VARCHAR(128) NOT NULL, password VARCHAR(128) NOT NULL, PRIMARY KEY (id) ) Engine=InnoDB CHARACTER SET 'latin1'; CREATE UNIQUE INDEX host_index ON ddclient(host);
mysql
mysql -updns -ppdns pdns < table.sql
Install
sudo -s cd /var/www hg clone https://hg.kewl.org/pub/ddns cd ddns mkdir -p /var/www/htdocs/example.com/ddns cp index.php var/www/htdocs/example.com/ddns
Configure
Copy config_example.php to config.php and edit.
Add host
./addhost.php host ipv4|ipv6 password
This adds a host with either a A or AAAA record with the specified password which will be encrypted.
The host is also the login username for ddclient.
The SOA serial is incremented by 1.
Delete host
./delhost.php host
The specified host is deleted.
The SOA serial is incremented by 1.
Update SOA
./update_soa.php [+]value
The value can replace the SOA serial or be added to the serial when prefixed by “+”.
Eg.
./update_soa.php 10000 ./update_soa.php +1
ddclient
See here.
Curl
#! /bin/bash
RESPONSE=$(curl -s http://user:pass@ipvX.example.com/ddns/?hostname=user.example.com)
echo $RESPONSE
STATUS=$(echo $RESPONSE | cut -d' ' -f1)
IPADDR=$(echo $RESPONSE | cut -d' ' -f2)
if test "$STATUS" = "good"; then
cd /var/www/htdocs/user.example.com && \
sudo -u www-data php occ config:app:set richdocuments wopi_allowlist --value "$IPADDR"
fi
exit 0
*/5 * * * * /script.sh 1>/dev/null 2>&1

