Skip to content
Dynamic DNS Zone Updater for WHM/cPanel
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
server Specified WHM API Version 1 and added better API response handling. Jun 11, 2018
LICENSE
README
class.Logger.php
class.Scraper.php
class.ZoneUpdater.php Specified WHM API Version 1 and added better API response handling. Jun 11, 2018
whmDynDns.config.sample.php
whmDynDns.php

README

What is whmDynDns?

whmDynDns is a PHP script which takes advantage of the WHM JSON API in order to update DNS zone
records for pointing subdomains to a server with a dynamic IP address. It can be run using CRON and
based on your configuration will add/update A records when your public IP address changes.


Why was it created?

Although I have my production websites hosted remotely I wanted to be able to point development
versions to my own server hosted at home with a dynamic IP address. i.e. http://www.myapplication.com
is hosted remotely but http://dev.myapplication.com is hosted locally on my own machine. After a little searching
I found the WHM JSON API and had to have some fun with it!


How to use whmDynDns?

Copy the whmDynDns.config.sample.php to whmDynDns.config.php and configure the following options:

// Set Log Level (0 = errors only, 1 = IP changes only, 2 = Everything)
const LOG_LEVEL =  1;

// Set your TimeZone
date_default_timezone_set('America/New_York');

Set this to your WHM Admin login
$username = 'YourUsername';

Set this to your WHM Admin password
$password = 'YourPassword';

Set this to your WHM Login URL (2087 is the default WHM SSL port)
$whmUrl = 'https://yourwhmwebsite.com:2087/';

Add one more more websites to scrape our IP from (one or more as array)
Included in the "server" folder is very simple PHP script you can upload
to a external server to get your remote IP.

$websites[] = 'http://www.differentwebsite.com/ip.php';
$websites[] = 'http://www.ipchicken.com';

Add your host names here (one or more as array).
'name' is the subdomain, if left empty, it will add/update a record for the root domain itself (ex, yourdomain.com.)
'zone' is the domain
'ttl' is the time to live of the record, if left empty, iit will be set as the DNS server default
$zones[] = array('name' => 'sub1', 'zone' => 'yourdomain.com');
$zones[] = array('name' => 'sub2', 'zone' => 'yourdomain.com', 'ttl' => 900);
$zones[] = array('name' => '', 'zone' => 'yourdomain.com');



Schedule with CRON

Setup whmDynDns.php to run at regular intervals using CRON (via 'crontab -e', etc.) and pipe to log!

i.e. Every fifteen minutes would look like:

*/15     *     *     *     *     php /home/phpguy/cron/whmDynDns.php >> /var/log/whmDynDns.log
You can’t perform that action at this time.