N
Nooze Goy
I'm in the process of setting up a web server - actually, it's pretty
much working, just a few irritating things lurking about, occasionally
leaping out and biting me on the arse.
One of the irritations is that with a dynamic DNS, I'm having to update
the IP addresses for the authoritative DNS server of multiple domains
hosted here. They're on one DNS service, ZoneEdit, and I found a couple
of pieces of code to update the IP addresses. One was ddclient, but
before I could get the config debugged, I tried another - which is not
so much a program as a command-line. It works okay, except that
ZoneEdit's server is agonizingly slow to respond, so it takes ten or
fifteen seconds to respond for each domain.
wget -O - --http-user=mylogin --http-passwd=myp455
'http://dynamic.zoneedit.com/auth/dynamic.html?host=my.domain.com'
In the script, the above line is repeated for each domain; each line
takes ten or fifteen seconds to process - doesn't seem reasonable, butt
hu nose?
Obviously, with five or six domains, you're going to be hard-pressed to
update the IP every minute, and with 20 domains you're basically looking
at five solid minutes of updating anytime the ISP changes the IP, so it
doesn't make any sense to update unless it's actually changed.
I wrote a little Perl script to check the IP and log it and compare with
last time it checked, and do the update only if the two don't match.
It works fine right now - all it does is run a bash script of the
command-line entries shown above. But, of course, it's still sllooowwwww
as molasses.
I'm assuming that there's some rational way to have my perl prog connect
to the DNS update server directly, and maybe a) that'll be faster or b)
there's some way to update all the domains in the list either with one
string or in a loop.
So... here's the code - feel free to throw rocks at it, but it works...
(barring typos - I'm looking at the code thru putty, and the copy and
paste from a terminal window leave a lot to be desired)
####################################################
#!/usr/bin/perl
use LWP::Simple;
$site = "http://checkip.dyndns.org";
$var = get $site;
$colloc = index($var,":");
$ip = substr($var,$colloc+2,20);
$angloc = index($ip,"<");
$ip = substr($ip,0,$angloc);
open CURIP,">curip" or die "File does not exist, 'curip'";
print CURIP "$ip";
close CURIP;
open OLDIP,"oldip";
$oldip = <OLDIP>;
close OLDIP
if ( $oldip == $ip ) {
# yep, yep... print "Look the same to me, too, ain't it???\n";
}
else
{ #update dns address - run script of
# wget lines and replace old IP value
system("./updns");
system("cp -f curip oldip");
}
###############################################
What should I use to send the update info direct to ZoneEdit?
much working, just a few irritating things lurking about, occasionally
leaping out and biting me on the arse.
One of the irritations is that with a dynamic DNS, I'm having to update
the IP addresses for the authoritative DNS server of multiple domains
hosted here. They're on one DNS service, ZoneEdit, and I found a couple
of pieces of code to update the IP addresses. One was ddclient, but
before I could get the config debugged, I tried another - which is not
so much a program as a command-line. It works okay, except that
ZoneEdit's server is agonizingly slow to respond, so it takes ten or
fifteen seconds to respond for each domain.
wget -O - --http-user=mylogin --http-passwd=myp455
'http://dynamic.zoneedit.com/auth/dynamic.html?host=my.domain.com'
In the script, the above line is repeated for each domain; each line
takes ten or fifteen seconds to process - doesn't seem reasonable, butt
hu nose?
Obviously, with five or six domains, you're going to be hard-pressed to
update the IP every minute, and with 20 domains you're basically looking
at five solid minutes of updating anytime the ISP changes the IP, so it
doesn't make any sense to update unless it's actually changed.
I wrote a little Perl script to check the IP and log it and compare with
last time it checked, and do the update only if the two don't match.
It works fine right now - all it does is run a bash script of the
command-line entries shown above. But, of course, it's still sllooowwwww
as molasses.
I'm assuming that there's some rational way to have my perl prog connect
to the DNS update server directly, and maybe a) that'll be faster or b)
there's some way to update all the domains in the list either with one
string or in a loop.
So... here's the code - feel free to throw rocks at it, but it works...
(barring typos - I'm looking at the code thru putty, and the copy and
paste from a terminal window leave a lot to be desired)
####################################################
#!/usr/bin/perl
use LWP::Simple;
$site = "http://checkip.dyndns.org";
$var = get $site;
$colloc = index($var,":");
$ip = substr($var,$colloc+2,20);
$angloc = index($ip,"<");
$ip = substr($ip,0,$angloc);
open CURIP,">curip" or die "File does not exist, 'curip'";
print CURIP "$ip";
close CURIP;
open OLDIP,"oldip";
$oldip = <OLDIP>;
close OLDIP
if ( $oldip == $ip ) {
# yep, yep... print "Look the same to me, too, ain't it???\n";
}
else
{ #update dns address - run script of
# wget lines and replace old IP value
system("./updns");
system("cp -f curip oldip");
}
###############################################
What should I use to send the update info direct to ZoneEdit?