Personal Dynamic DNS Server

Assumptions:

  • You wish to use a dynamic DNS updater client such as ddclient to remotely update the DNS record of a host.
  • You already have a Bind DNS server installed.
  • You have a NS DNS record that points to your Bind DNS server (for example, at ns.example.com).
  • You have a web server running PHP.
    First, add a new zone for dynamic addresses to your Bind configuration. This is done by creating a new zone file, “/etc/bind/zones/master/dyn.example.com.db” (create the directory if it doesn’t already exist). Add some appropriate TTLs. For example:
1
2
3
4
5
6
7
8
9
10
11
$ORIGIN dyn.example.com.
$TTL 10 ; 10 seconds
dyn.example.com. IN SOA ns.example.com. hostmaster.example.com. (
18 ; serial
10800 ; refresh (3 hours)
3600 ; retry (1 hour)
604800 ; expire (1 week)
10 ; minimum (10 seconds)
)
$TTL 3600 ; 1 hour
NS ns.example.com.

Save the zone file and then add these lines to /etc/bind/named.conf.local:

1
2
3
4
5
zone "dyn.example.com" {
type master;
file "/etc/bind/zones/master/dyn.example.com.db"
allow-update { 127.0.0.1; };
};

replacing the path to point to the location of the zone file you just created. If the web server that listens to update requests from clients (that we will set up below) is not on the same machine as Bind, it has to be added to “allow-update” above instead of “127.0.0.1”.

Now download this script and put it the appropriate directory so that it is accessible on your web server at “/nic/update” (for example, “dns.example.com/nic/update”): update.php

You will need to use Apache’s MultiViews or mod_rewrite to ensure that the script is accessible at “/nic/update” and not just “/nic/update.php”.

Update the config section to contain the correct zone information along with the authentication credentials that the dynamic DNS updater client script will use. ddclient is such a client.