[ previous ] [ next ] [ threads ]
 From:  Hans Mathre <hanzcc at gmail dot com>
 To:  m0n0wall dash dev at lists dot m0n0 dot ch
 Subject:  Working with ENom or the like dynamic DNS system...
 Date:  Tue, 6 Sep 2005 20:36:24 -0400
I just finished kludging together some scripts to work with enom's dynamic 
DNS servers if anyone is interested. 
I'll warn you know its really rough, but it seems to be working for me.

I've employed the "shellcmd" entry in the config.xml, the minicron, and a 
separate php file that is copied from either the floppy disk or the CF card.

here is the enom.php code

//{{{ Functions
function fetchURL( $url ) {
 $url_parsed = parse_url($url);
 $host = $url_parsed["host"];
 $port = $url_parsed["port"];
 if ($port==0)
 $port = 80;
 $path = $url_parsed["path"];
 if ($url_parsed["query"] != "")
 $path .= "?".$url_parsed["query"];
 $out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
 $fp = fsockopen($host, $port, $errno, $errstr, 30);
 fwrite($fp, $out);
 $body = false;
 while (!feof($fp)) {
 $s = fgets($fp, 1024);
 if ( $body )
 $in .= $s;
 if ( $s == "\r\n" )
 $body = true;
 return $in;
//Pull the vars from the saved files of the config.xml shellcmd
$dhz=trim(`cat /var/db/dhz`);
$dhp=trim(`cat /var/db/dhp`);
$dhn=trim(`cat /var/db/dhn`);

//Make sure there is something there, and drop the cron if not
if (!$dhz || !$dhp || !$dhn){
 $kill=trim(`cat /var/run/enom.pid`);
 $kill=`kill $kill`;
 exit("something is wrong with enom and killed $kill");

//grab the IP's for a diffrence check, initally there will not be a dynip
$dip=trim(`cat /var/db/dynip`);
$cip=trim(`cat /var/db/wanip`);

//Check for a diffreance
if ($dip!=$cip){
 //Update the dynip record
 $update=`echo $cip > /var/db/dynip`;
}else {
 //place some type of 'hey it worked thing here', I just had it send a note 
to a web server and looked in the log

//Print out the note for running it directly

End of the enom.php code. Now I placed this file into the disk under the 
conf folder. After this is in place, then download a copy of your config.xml, 
and add the following lines. to add this file to a cf, or disk system, I 
just ran a 'umount /cf' and did a 'mount -o rw /dev/ad0a /cf' (change your 
dev to fit your needs), uploaded the enom.php to the tmp folder, and copied 
it to the conf directory of the /cf mount, and finally 'umount /cf' and 
'mount /cf'. 

First we define some information, like the domain name... (don't forget the 
'&gt;' for xml)
<shellcmd>echo domain.com <http://domain.com> &gt; /var/db/dhz</shellcmd>
the host name
<shellcmd>echo hostname &gt; /var/db/dhn</shellcmd>
and the password.
<shellcmd>echo password &gt; /var/db/dhp</shellcmd>

Next we copy the file from the conf directory and move it into the ramdisk, 
make it executable, and run it once.
<shellcmd>cp /cf/conf/enom.php /usr/local/www/enom.php</shellcmd>
<shellcmd>chmod 755 /usr/local/www/enom.php</shellcmd>

Finally we use the minicron to run it every 6 hours (in seconds), change to 
your preference. 
<shellcmd>/usr/local/bin/minicron 21600 /var/run/enom.pid 

Anyway, after that is all in place, the monowall will check the IP every 6 
hours for a change and send said change to enom's server. 

Please tell me what you think, as this is my first attempt to modify 
monowall beyond the hidden config.xml features. I just though I should give 
back to the developers for such a great product.