Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Dynamic DNS management

Reply
Thread Tools

Dynamic DNS management

 
 
Nooze Goy
Guest
Posts: n/a
 
      05-01-2007
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?
 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      05-02-2007
On May 2, 12:42 am, Nooze Goy <(E-Mail Removed)> wrote:
> 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,


Unless you spawn 5 or 6 wget commands at once.

> 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,


There's Net:NS if the server accepts standard DNS updates.

> and maybe a) that'll be faster


That's a question about dynamic.zoneedit.com

> or b)
> there's some way to update all the domains in the list either with one
> string


That is a question about the HTTP GET API presented at
http://dynamic.zoneedit.com/auth/dynamic.html

> or in a loop.


A loop would be no faster.

> 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)


I've never had any such problem with PuTTY.

> ################################################## ##
> #!/usr/bin/perl


Unless you enjoy pain:

use strict;
use warnings;

> use LWP::Simple;


In my experience LWP::Simple is only suited to run once and throw away
scripts. For anything else the small additional effort of using the
real LWP API pays off.

> $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);


Perl has very good pattern matching. Use it.

my ($ip) = get('http://checkip.dyndns.org') =~ /Current IP Address:
(.*?)</;

> open CURIP,">curip" or die "File does not exist, 'curip'";


Consider putting the actual error in the error message rather than an
random guess. Use the 3-arg open() unless you actually understand the
special legacy 2-arg form and require those semantics.

open CURIP,'>','curip' or die "$!, 'curip'";

> print CURIP "$ip";


See FAQ: What's wrong with always quoting "$vars"?

> close CURIP;


> open OLDIP,"oldip";


Use the 3-arg open() unless you actually understand the special legacy
2-arg form and require those semantics. Always check success.

> $oldip = <OLDIP>;
> close OLDIP
> if ( $oldip == $ip ) {


If you'd enabled warnings perl would have told you what's wrong with
that line (so I won't).

> # 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");


Wouldn't it make more sense to do away with the curip file and just
update the oldip file dirtectly from $ip at this point?

> }
> ###############################################
>
> What should I use to send the update info direct to ZoneEdit?


Well, if you want to stick to the HTTP GET API at
http://dynamic.zoneedit.com/auth/dynamic.html then you should simply
use LWP.

For an example of this download the example Perl script from the
dynamic.zoneedit.com site. (Like, duh!)

Note: this example script is not written in very good Perl.

If you want to do several requests in parallel then you could fork()
or use LWP:arallel.

 
Reply With Quote
 
 
 
 
Nooze Goy
Guest
Posts: n/a
 
      05-03-2007
Brian McCauley wrote:
> On May 2, 12:42 am, Nooze Goy <(E-Mail Removed)> wrote:
>> 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,

>
> Unless you spawn 5 or 6 wget commands at once.


How?
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      05-03-2007
On May 3, 5:51 pm, Nooze Goy <(E-Mail Removed)> wrote:
> Brian McCauley wrote:
> > On May 2, 12:42 am, Nooze Goy <(E-Mail Removed)> wrote:


[ talking about a Unix shell script ]

> >> 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


> >> Obviously, with five or six domains, you're going to be hard-pressed to
> >> update the IP every minute,

>
> > Unless you spawn 5 or 6 wget commands at once.

>
> How?


You are asking (in a Perl newsgroup) how, in a Unix shell script, to
indicate that the script should not wait for one command to complete
before going on to the next!

What's wrong with this picture?

Oh, well, I guess seeing as it's a single character answer:

&

 
Reply With Quote
 
Nooze Goy
Guest
Posts: n/a
 
      05-03-2007
Brian McCauley wrote:
> On May 3, 5:51 pm, Nooze Goy <(E-Mail Removed)> wrote:
>> Brian McCauley wrote:
>>> On May 2, 12:42 am, Nooze Goy <(E-Mail Removed)> wrote:

>
> [ talking about a Unix shell script ]
>
>>>> 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

>
>>>> Obviously, with five or six domains, you're going to be hard-pressed to
>>>> update the IP every minute,
>>>>
>>> Unless you spawn 5 or 6 wget commands at once.

>> How?

>
> You are asking (in a Perl newsgroup) how, in a Unix shell script, to
> indicate that the script should not wait for one command to complete
> before going on to the next!
>
> What's wrong with this picture?


There's nothing wrong with the picture - there's a flaw in your
attitude. No question was asked about the script, but you chose to make
a statement about it. Now you act amazed that there was a response to
that...

Man, if you don't want to help, then don't answer. If you're going to
change directions, then don't jump sh!tty when your direction is followed.

Basically, what's wrong is that YOU offered a response to a question
that wasn't asked. You could have taken the few seconds to explain, but
apparently you were too busy deconstructing my crappy little Perl script
- which, as pathetic as it may be, does in fact work. Near as I could
tell, the slowth is on the other end, at least through its current
access method, but I thought perhaps someone else might be handling
dyndns differently and have something useful to offer.

My mistake. Thanks, anyway.





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VPN between peers with dynamic IP address and dynamic DNS Diego Balgera Cisco 5 02-08-2008 01:20 PM
PIX 501 relay client DNS requests out to an internet DNS server? nicough@gmail.com Cisco 1 11-18-2006 03:29 PM
DNS query to internal DNS server from static NAT host none Cisco 5 04-25-2006 03:11 AM
DNS query from outside to internal, public DNS server Lars Bonnesen Cisco 9 04-08-2006 11:16 AM
DNS question - reverse DNS getting cluttered Jose Padilla Computer Support 0 01-21-2004 10:29 PM



Advertisments