My First Own DynDNS
-------------------------------------------------------------------------------
PHP code for a self hosted dynDNS compatible dynamic DNS system

* Author Stefan Onderka
* Contact http://www.onderka.com/about/
* First version (for Bind):
  [1] http://www.onderka.com/inhalt/eigener-dyndns-mit-bind-apache-und-php/
* Newer version (for Bind and dnsmasq): 
  [2] http://www.onderka.com/inhalt/eigener-dyndns-mit-dnsmasq-apache-und-php/

Requirements
-------------------------------------------------------------------------------
* Bind or dnsmasq
* PHP
* Apache or Lighttpd web server with PHP support
* Apache mod_rewrite or equivalent for DynDNS compatibility ("/nic/update?..." style URLs)

Installation and setup of your nameserver
-------------------------------------------------------------------------------
* When using Bind:
  * Create a zone for your dynamic DNS, for example ddns.example.com
  * Create an nsupdate key that is allowed to update your zone
  * Set up Bind to allow the created key for updates to the DDNS zone
* whe using dnsmasq:
  * Configure dnsmasq to use an include folder:
    conf-dir=/var/www/dyndns-vhost/dnsmasq/,*.conf

The setup until here is beyond the scope of this readme. Some hints:

* http://andrwe.org/linux/own-ddns
* http://linux.yyz.us/nsupdate/
* http://blog.philippklaus.de/2013/01/updating-dns-entries-with-nsupdate-or-alternative-implementations-your-own-ddns/
* http://www.thekelleys.org.uk/dnsmasq/docs/FAQ

Installation and setup of this software
-------------------------------------------------------------------------------
* Create and configure a virtual host on your webserver like ddns.example.com
* Unpack this archive to the document root of your vhost
* Make all files and folders readable, log/ and data/ writeable for the server
* Configure include/config.php, customize at least:
  DNSSOFTWARE - Select 'dnsmasq' or 'bind'
  SOA_RNAME   - Address per RFC 2142
  DNS_SERVER  - Probably '127.0.0.1'
  DDNS_ZONE   - Zone name, like 'ddns.example.com'
  KEY_VALUE   - DNS key, like '5FTbonMto3qewfEFQEqafQWEAFVADVssC+jc1A=='
* When using Bind, you should be all set up now.
* When using dnsmasq, install 'iwatch' and add a watchlist for the dnsmasq 
  include folder to your iwatch.xml:

     <watchlist>
       <title>dnsdmasq</title>
       <contactpoint email="root@example.com" name="DynDNS-admin"/>
       <path type="single" syslog="off" events="modify" alert="off"
       exec="/data/scripts/inotify_ddns.sh">/var/www/ddns.example.com/dnsmasq/soa.conf</path>
     </watchlist>

* Set up the bash script (/data/scripts/inotify_ddns.sh) called by iwatch
  * Use the code at link [2] above as a starting point
* Configure include/users.php, USERNAME is also HOSTNAME.ddns.example.com
  * Example: $known_clients['home'] = "home$$pASSw0rd";
  * User "home" / pass "home$$pASSw0rd" is for updating home.ddns.example.com

* Test your system with a browser first
  * Unauthenticated bypassers simply get their IP displayed.
    http://ddns.example.com/
  * Simple update URL:
    http://ddns.example.com/?name=home&pass=home$$pASSw0rd
  * DynDNS compatible update URL:
    http://ddns.example.com/nic/update?name=home&pass=home$$pASSw0rd
    (Rewriting from /nic/update?... to /index.php?... is done in .htaccess)
  * Shortest way, not supported by many modern _browsers_ - use cURL etc.:
    http://home:home$$pASSw0rd@ddns.example.com
  * Simple cURL command line:
    curl -v -s "http://home:home$$pASSw0rd@ddns.example.com"

* Server replies per DynDNS protocol (http://www.noip.com/integrate/response):
  * "good IP_ADDRESS"  - Host updated
  * "nochg IP_ADDRESS" - No change since last update
  * "badauth"          - Invalid user/password
  * "911"              - Internal server error

Files
-------------------------------------------------------------------------------
favicon.ico            - An icon. You guessed it. Ripped from DynDNS
index.php              - Main php file
.htaccess              - Basic settings and rewriting of DynDNS protocol URLs
data/${client}.ip      - Stored client IPs
dsnamasq/*.conf        - Host entries and SOA config for dnsmasq
include/config.php     - System configuration
include/functions.php  - Functions
include/users.php      - DynDNS user setup
log/debug.log          - Log for debugging
log/events.log         - Log for events
