enomddu is a Dynamic DNS update utility for use with the registrar eNom. We have scripts written in Bash, PERL and PHP. eNom is a great service provider; Edoceo and our clients have trusted them for years. With their Dynamic DNS it's possible to create names under your domain that are on a dynamic IP address, awesome.
If your office is on a dynamic IP address, as some broadband providers do, this script could be run from some host in there to keep office.yourdomain.com pointed to the office internet connection. Then your VPN clients and other allowed traffic can point to the constant name, not the ever changing IP address. The Curo Small Business Server, which provides VPN remote access servies, uses Bash version of this tool.
To use setup a cron job (or however your system schedules tasks) to run this script every five minutes. Five minutes is the suggested value by eNom, but in our experience once an hour was acceptable. Adjust the paths for where ever this script was saved, the PEAR::HTTP_Request package is also needed, refer to your system or PHP documentation.
# fcron @5 /opt/edoceo/bin/enomddu # dcron/vixie-cron */5 * * * * /opt/edoceo/bin/enomddu
This script depends on having Perl's URI::Encode module.
#!/bin/bash
# $Id$
# spec: enomddu.sh - eNom Dynamic DNS Update with Bash
hostname=$(/usr/bin/hostname)
password='password'
zonename='edoceo.com'
# Must have the PERL module URI::Escape
url_hostname=$(echo $hostname | perl -MURI::Escape -lne 'print uri_escape($_)')
url_password=$(echo $password | perl -MURI::Escape -lne 'print uri_escape($_)')
url_zonename=$(echo $zonename | perl -MURI::Escape -lne 'print uri_escape($_)')
enom_url='http://dynamic.name-services.com/interface.asp?Command=SetDNSHost'
enom_url="${enom_url}&HostName=${url_hostname}"
enom_url="${enom_url}&DomainPassword=${url_password}"
enom_url="${enom_url}&Zone=${url_zonename}"
curl $enom_url > /dev/null
This can also be downloaded from here.
This script depends on the PEAR extension HTTP_Request.
#!/usr/bin/php
<?php
/*
auth: David Busby, edoceo inc, http://www.edoceo.com/
spec: enomddu - eNom Dynamic DNS Update
note: See eNom FAQ at http://www.enom.com/help/faq_dynamicdns.asp
*/
error_reporting(E_ALL);
require_once('HTTP/Request.php');
// Change this for your environment
define('DDU_HOST',`/usr/bin/hostname`); // Or hardcode
define('DDU_PASS','password');
define('DDU_ZONE','edoceo.com'); // Domain to update
// Set to 1 to lookup your IP address with dyndns.org
define('MANUAL_IP_LOOKUP',0); // Not necessary
$debug = getenv('debug');
$ip_pat = '/Current IP Address: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/';
$dd_url = 'http://dynamic.name-services.com/interface.asp?Command=SetDNSHost';
$dd_url.= '&Zone='.urlencode(DDU_ZONE);
$dd_url.= '&DomainPassword='.urlencode(DDU_PASS);
$dd_url.= '&HostName='.urlencode(DDU_HOST);
if (MANUAL_IP_LOOKUP)
{
if ($debug) echo "Performing Manual IP lookup\n";
$req = &new HTTP_Request('http://checkip.dyndns.org');
$req->sendRequest();
$res = $req->getResponseBody();
if (!preg_match($ip_pat,$res,$m)) die("Cannot Parse IP from $ip_url\n");
$dd_url.= '&Address='.urlencode($m[1]);
}
if ($debug) echo "Updating: $dd_url\n";
$req = &new HTTP_Request($dd_url);
$req->sendRequest();
$res = $req->getResponseBody();
echo $res;
?>
This can also be downloaded from here.