Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Update DNS Made Easy DDNS Record with Local IP
#!/usr/bin/php
<?php
/**
* Update DNS Made Easy DDNS Record with Local IP
* http://www.joelambert.co.uk
*
* Copyright 2012, Joe Lambert.
* Free to use under the MIT license.
* http://joelambert.mit-license.org/
*/
// The record you wish to update
$dns_record = array(
// A label representation of the record
'label' => "*.mydomain.com",
// The DNS record's ID - found in the DNS Made easy control panel
'id' => 123456,
);
// Your DDNS username/password
$username = "username";
$password = "password";
// Work out the local IP Address
exec('ifconfig en1', $response);
$response = implode("\n", $response);
preg_match("/inet ([0-9\.]+)/", $response, $matches);
$new_ip = $matches[1];
// Make the API Call
echo "Updating {$dns_record['label']} to $new_ip\n";
$response = file_get_contents("http://www.dnsmadeeasy.com/servlet/updateip?username={$username}&password={$password}&id={$dns_record['id']}&ip={$new_ip}");
echo trim($response) . "\n";
// Clear the local DNS cache
exec('dscacheutil -flushcache');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment