Re: Net::DNS::Resolver
What output do you get when you don't turn off debug? -- I found what is causing this, $query is 'undef' So was it the intent of the person who wrote this module to have this code act in this way? Do you have a recommendation on how to make this more usable in terms of success/failure lookups for client nodes on each BIND server? my $query = $res->query("CLIENT_IP"); use Data::Dumper; print Dumper($query); using Data::Dumper with debug off I get: $VAR1 = undef; but with debug on, I seem to get an answer __OUTPUT__ ;; query(x.x.x.x) ;; setting up an AF_INET() family type UDP socket ;; send_udp(x.x.x.x) ;; answer from x.x.x.x:53 : 43 bytes ;; HEADER SECTION ;; id = 6637 ;; qr = 1opcode = QUERYaa = 0tc = 0rd = 0 ;; ra = 1ad = 0cd = 0rcode = SERVFAIL ;; qdcount = 1 ancount = 0 nscount = 0 arcount = 0 ;; QUESTION SECTION (1 record) ;; x.x.x.x.in-addr.arpa. IN PTR ;; ANSWER SECTION (0 records) ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (0 records) RCODE: SERVFAIL; trying next nameserver ;; send_udp(x.x.x.x:53) ;; answer from x.x.x.x:53 : 474 bytes ;; HEADER SECTION ;; id = 6637 ;; qr = 1opcode = QUERYaa = 0tc = 0rd = 0 ;; ra = 1ad = 0cd = 0rcode = NOERROR ;; qdcount = 1 ancount = 0 nscount = 13 arcount = 13 ;; QUESTION SECTION (1 record) ;; x.x.x.x.in-addr.arpa. IN PTR ;; ANSWER SECTION (0 records) ;; AUTHORITY SECTION (13 records) . $VAR1 = undef; A manual nslookup does work : # nslookup Default Server: xxx.xxx.xxx.com Address: 10..xx.xx.xx > server ns7.xx.com Default Server: ns7.xx.com Address: xx.xx.xx.xx > 10.8.xx.xx## Client IP Server: ns7.xx.com Address: xx.xx.xx.xx Name:xxx.xxx.xxx.com Address: 10.xx.xx.254 > server xxx.xxx.xxx.com Default Server: xxx.xxx.xxx.com Address: 10.220.xx.xx > 10.8.xx.xx ## Client IP Server: xx.xx.xx.com Address: 10.220.13.132 Name:xxx.xxx.xxx.com Address: 10.8.xx.xx __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Net::DNS::Resolver
> Why is it when I turn off debug mode, I get no output? What output do you get when you don't turn off debug? -- I found what is causing this, $query is 'undef' So was it the intent of the person who wrote this module to have this code act in this way? Do you have a recommendation on how to make this more usable in terms of success/failure lookups for client nodes for each BIND server? my $query = $res->query("CLIENT_IP"); use Data::Dumper; print Dumper($query); using Data::Dumper with debug off I get: $VAR1 = undef; but with debug on, I seem to get an answer __OUTPUT__ ;; query(x.x.x.x) ;; setting up an AF_INET() family type UDP socket ;; send_udp(x.x.x.x) ;; answer from x.x.x.x:53 : 43 bytes ;; HEADER SECTION ;; id = 6637 ;; qr = 1opcode = QUERYaa = 0tc = 0rd = 0 ;; ra = 1ad = 0cd = 0rcode = SERVFAIL ;; qdcount = 1 ancount = 0 nscount = 0 arcount = 0 ;; QUESTION SECTION (1 record) ;; x.x.x.x.in-addr.arpa. IN PTR ;; ANSWER SECTION (0 records) ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (0 records) RCODE: SERVFAIL; trying next nameserver ;; send_udp(x.x.x.x:53) ;; answer from x.x.x.x:53 : 474 bytes ;; HEADER SECTION ;; id = 6637 ;; qr = 1opcode = QUERYaa = 0tc = 0rd = 0 ;; ra = 1ad = 0cd = 0rcode = NOERROR ;; qdcount = 1 ancount = 0 nscount = 13 arcount = 13 ;; QUESTION SECTION (1 record) ;; x.x.x.x.in-addr.arpa. IN PTR ;; ANSWER SECTION (0 records) ;; AUTHORITY SECTION (13 records) . 10302 IN NS i.root-servers.net. . 10302 IN NS g.root-servers.net. . 10302 IN NS k.root-servers.net. . 10302 IN NS b.root-servers.net. . 10302 IN NS c.root-servers.net. . 10302 IN NS f.root-servers.net. . 10302 IN NS e.root-servers.net. . 10302 IN NS d.root-servers.net. . 10302 IN NS m.root-servers.net. . 10302 IN NS l.root-servers.net. . 10302 IN NS j.root-servers.net. . 10302 IN NS a.root-servers.net. . 10302 IN NS h.root-servers.net. ;; ADDITIONAL SECTION (13 records) i.root-servers.net. 10302 IN A 192.36.148.17 g.root-servers.net. 10302 IN A 192.112.36.4 k.root-servers.net. 10302 IN A 193.0.14.129 b.root-servers.net. 10302 IN A 192.228.79.201 c.root-servers.net. 10302 IN A 192.33.4.12 f.root-servers.net. 10302 IN A 192.5.5.241 e.root-servers.net. 10302 IN A 192.203.230.10 d.root-servers.net. 10302 IN A 128.8.10.90 m.root-servers.net. 10302 IN A 202.12.27.33 l.root-servers.net. 10302 IN A 198.32.64.12 j.root-servers.net. 10302 IN A 192.58.128.30 a.root-servers.net. 10302 IN A 198.41.0.4 h.root-servers.net. 10302 IN A 128.63.2.53 $VAR1 = undef; __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Net::DNS::Resolver
On 10/24/07, oryann9 <[EMAIL PROTECTED]> wrote: > Why is it when I turn off debug mode, I get no output? Are you saying that there's a difference in your program's execution depending upon whether Perl's debugger (activated via the -d command line switch) is or is not running? If that's the case, unless somebody is trying to make that happen, the evidence points to a bug in perl (specifically, in the optimizer; since that isn't used when the debugger is running). Or are you talking about a debug mode for the module itself? If that's the problem, you could search the source for places the debug mode is checked. Also, in contrast to the previous case, you can use the Perl debugger to step through the Perl parts of the module and see what's really happening. Or not, as the case may be. (If there's any compiled code, the Perl debugger may not be much help.) It may also be that turning on a debug mode slows down the execution sufficiently to match the speed of a server, or something like that. It seems unlikely in this case, but I've heard of servers which fail when sent multiple requests in a short time interval without a delay. This is the kind of bug that may not show up until you use a fast enough machine against a slow enough server, so you may be the first to be bitten by this bug. You may want to try adding a small delay at key places in your code, to see whether that makes things run better. select(undef, undef, undef, 0.2); # small delay Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Net::DNS::Resolver
On Oct 24, 4:22 pm, [EMAIL PROTECTED] (Oryann9) wrote: > Why is it when I turn off debug mode, I get no output? What output do you get when you don't turn off debug? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Net::DNS::Resolver
All, Why is it when I turn off debug mode, I get no output? I was expecting output similar to what nslookup shows for a simple query. My goal is to look up by NAME and by IP within 2 domains to determine success and failure. use strict; use warnings; use Carp; my $res = Net::DNS::Resolver->new( nameservers => [qw(n.com x.com)], recurse => 0, debug => 1, ); my $query = $res->query("CLIENT IP"); if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "A"; ## Skip if not a host address record ## print $rr->address, "\n"; } } else { warn "query failed: ", $res->errorstring, "\n"; } thank you! __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: blacklist monitoring with Net::DNS::Resolver
have you tried reversing the array and joining it with a "."? On Mon, 14 Feb 2005 18:38:36 +0100, Mariano Cunietti <[EMAIL PROTECTED]> wrote: > Hi, > I'm writing a simple script to perform some periodical checks on dns > blacklist, so I can be quickly informed when one of my mail servers gets > blacklisted. > What I want is a function to query in-addr.arpa DNS and return an IP > address. > I used Net::DNS::Resolver, but the output is too long, and I need > something more easy to be parsed. In other words, I need only the ANSWER > SECTION (which maybe an A resurce or a CNAME and A response). > > Here's the code (it's a draft, don't blame me): > > = > #!/usr/bin/perl > use strict; > use warnings; > > use Net::DNS; > > my @servers = qw( > 219.147.99.89 > 212.29.141.7 > 212.29.130.207 > 212.29.130.208 > 212.29.129.3 > 212.29.129.4 > 212.29.141.3 > 212.29.141.33 > 212.29.141.34 > ); > my @dnsbl = qw( > dnsbl.njabl.org > list.dsbl.org > dnsbl.sorbs.net > sbl.spamhaus.org > opm.blitzed.org > bl.spamcop.net > dynablock.njabl.org > rfc-ignorant.org > blackholes.five-ten-sg.com > cbl.abuseat.org > ); > > my $res = Net::DNS::Resolver->new; > foreach my $server (@servers) { > my @octets =split(/\./,$server); > my $prep_server = > $octets[3].".".$octets[2].".".$octets[1].".".$octets[0]; > foreach my $blacklist (@dnsbl) { > my $inaddrarpa = "$prep_server.$blacklist"; > my $answer = $res->query("$inaddrarpa", 'A'); > next unless ($answer); > $answer->print; > } > } > } > > = > > Questions: > 1 - Is there a better module to performs easy DNS queries? > 2 - Is there a function to invert items in an array? (IP octects must be > inverted before submitting) > 3 - Which is the best module to send the report directly from the > script? > TIA > > Mariano > > -- > - > Mariano Cunietti > System Administrator > Enter S.r.l. > Via Stefanardo da Vimercate, 28 > 20128 - Milano - Italy > Tel. +39 02 25514319 > Fax +39 02 25514303 > [EMAIL PROTECTED] > www.enter.it - www.enterpoint.it > - > Gruppo Y2K - www.gruppoy2k.it > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
blacklist monitoring with Net::DNS::Resolver
Hi, I'm writing a simple script to perform some periodical checks on dns blacklist, so I can be quickly informed when one of my mail servers gets blacklisted. What I want is a function to query in-addr.arpa DNS and return an IP address. I used Net::DNS::Resolver, but the output is too long, and I need something more easy to be parsed. In other words, I need only the ANSWER SECTION (which maybe an A resurce or a CNAME and A response). Here's the code (it's a draft, don't blame me): = #!/usr/bin/perl use strict; use warnings; use Net::DNS; my @servers = qw( 219.147.99.89 212.29.141.7 212.29.130.207 212.29.130.208 212.29.129.3 212.29.129.4 212.29.141.3 212.29.141.33 212.29.141.34 ); my @dnsbl = qw( dnsbl.njabl.org list.dsbl.org dnsbl.sorbs.net sbl.spamhaus.org opm.blitzed.org bl.spamcop.net dynablock.njabl.org rfc-ignorant.org blackholes.five-ten-sg.com cbl.abuseat.org ); my $res = Net::DNS::Resolver->new; foreach my $server (@servers) { my @octets =split(/\./,$server); my $prep_server = $octets[3].".".$octets[2].".".$octets[1].".".$octets[0]; foreach my $blacklist (@dnsbl) { my $inaddrarpa = "$prep_server.$blacklist"; my $answer = $res->query("$inaddrarpa", 'A'); next unless ($answer); $answer->print; } } } = Questions: 1 - Is there a better module to performs easy DNS queries? 2 - Is there a function to invert items in an array? (IP octects must be inverted before submitting) 3 - Which is the best module to send the report directly from the script? TIA Mariano -- - Mariano Cunietti System Administrator Enter S.r.l. Via Stefanardo da Vimercate, 28 20128 - Milano - Italy Tel. +39 02 25514319 Fax +39 02 25514303 [EMAIL PROTECTED] www.enter.it - www.enterpoint.it - Gruppo Y2K - www.gruppoy2k.it -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>