Skip to content

silasmontgomery/whmDynDns

Repository files navigation

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

About

Dynamic DNS Zone Updater for WHM/cPanel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages