Re: Resolve hostname by specified nameserver
Why can't u use Net::DNS? It's pure Perl so there shouldn't be any trouble using it anywhere on Windows. It doesn't have to be installed globally to use it. U can copy it into ur own directory and do a use lib in ur script to load it. Even in the worst case scenario u can copy all of the Net::DNS code directly in ur own script. At 04:34 PM 10/20/2009 +0200, rocku wrote: Hello, I need to resolve a hostname by a specified nameserver. Currently I am using nslookup throught backticks, but it's output differs slightly between Windows versions and is hard to parse. I wanted to use Socket and something like inet_ntoa(inet_aton('hostname')) but this way I have no option to specify the nameserver to query. I am aware about Net::DNS, but unfortunately I cannot use it because it's not standard in ActivePerl 5.10. An ideal solution would be some WMI function, but I cannot find any for the task. Maybe using Win32::API? So my question is - how to query a specific nameserver about a DNS 'A' record? -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Resolve hostname by specified nameserver
No, it's not pure Perl. It uses some XS code. I can't use it since in my project I am limited to standard ActivePerl modules. I could, of course, copy it if it wasn't for this C code. Chris Wagner pisze: Why can't u use Net::DNS? It's pure Perl so there shouldn't be any trouble using it anywhere on Windows. It doesn't have to be installed globally to use it. U can copy it into ur own directory and do a use lib in ur script to load it. Even in the worst case scenario u can copy all of the Net::DNS code directly in ur own script. At 04:34 PM 10/20/2009 +0200, rocku wrote: Hello, I need to resolve a hostname by a specified nameserver. Currently I am using nslookup throught backticks, but it's output differs slightly between Windows versions and is hard to parse. I wanted to use Socket and something like inet_ntoa(inet_aton('hostname')) but this way I have no option to specify the nameserver to query. I am aware about Net::DNS, but unfortunately I cannot use it because it's not standard in ActivePerl 5.10. An ideal solution would be some WMI function, but I cannot find any for the task. Maybe using Win32::API? So my question is - how to query a specific nameserver about a DNS 'A' record? -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Resolve hostname by specified nameserver
On Tue, 20 Oct 2009 16:34 +0200, rocku rock...@gmail.com wrote: Hello, I need to resolve a hostname by a specified nameserver. Currently I am using nslookup throught backticks, but it's output differs slightly between Windows versions and is hard to parse. I wanted to use Socket and something like inet_ntoa(inet_aton('hostname')) but this way I have no option to specify the nameserver to query. I am aware about Net::DNS, but unfortunately I cannot use it because it's not standard in ActivePerl 5.10. An ideal solution would be some WMI function, but I cannot find any for the task. Maybe using Win32::API? So my question is - how to query a specific nameserver about a DNS 'A' record? -- rocku You sure don't need Net::DNS for that. Here is a very simple script that list all ip's associated to a hostname (or any name known on your DNS). I use the same script on windows or linux it just work asis : -- #!/usr/bin/perl -w #--#- # Param 1 = windows name of a machine # Return = IP or list of IP of that machine # # # use Socket; my $poste = $ARGV[0]; if (!$poste) {$poste = localhost;} # gethostbyname method my $host = (gethostbyname ($poste))[0]; print \n; printf Adresse(s) IP de $host\n; my @addr = gethostbyname ($host); splice @addr, 0, 4; print \n; foreach (@addr) { printf \t%s\n, inet_ntoa ($_); } - I wish to give credit to an unknow author on PerlMonks ( http://www.perlmonks.org/ ) from wich I took inspiration and some lines of code few years ago. Good luck, BT _ Une foule d’offres Windows 7 fantastiques, toutes à un endroit pratique. Trouvez dès maintenant l’aubaine idéale pour vous. http://go.microsoft.com/?linkid=9691643___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Resolve hostname by specified nameserver
Yes, the reason is that I am limited to standard ActivePerl modules. Serguei Trouchelle pisze: rocku wrote: I am aware about Net::DNS, but unfortunately I cannot use it because it's not standard in ActivePerl 5.10. Is there any reason not to run ppm install Net::DNS to install it? ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Resolve hostname by specified nameserver
Take a look at http://rallenhome.com/books/dnsonw2k3/toc.html I found a VBScript that did something very close to what you're trying to do. The differences are/could be: - queries needed to be directed to a domain controller - queries were only successful in the same domain [i.e., asking about fabrikam.com A records inside the fabrikam.com domain] ' Perform an SRV record query ' --- ' From the book DNS on Windows Server 2003 ' By Cricket Liu, Matt Larson Robbie Allen ' Publisher: O'Reilly and Associates ' ISBN: 0-596-00562-8 ' Book web site: http://rallenhome.com/books/dnsonw2k3/toc.html ' --- Unfortunately, the site that used to host the code appears to be no longer hosts it. I found in google.com's cache and in bing.com's cache... http://cc.bingj.com/cache.aspx?q=perform+an+srv+queryd=76844041126311mkt=en-USsetlang=en-USw=1f6e49b4,a90da8c2 -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of rocku Sent: Tuesday, October 20, 2009 10:35 AM To: perl-win32-users@listserv.activestate.com Subject: Resolve hostname by specified nameserver Hello, I need to resolve a hostname by a specified nameserver. Currently I am using nslookup throught backticks, but it's output differs slightly between Windows versions and is hard to parse. I wanted to use Socket and something like inet_ntoa(inet_aton('hostname')) but this way I have no option to specify the nameserver to query. I am aware about Net::DNS, but unfortunately I cannot use it because it's not standard in ActivePerl 5.10. An ideal solution would be some WMI function, but I cannot find any for the task. Maybe using Win32::API? So my question is - how to query a specific nameserver about a DNS 'A' record? -- rocku ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Resolve hostname by specified nameserver
2009/10/20 rocku rock...@gmail.com: So my question is - how to query a specific nameserver about a DNS 'A' record? See the first example in the Net::DNS manpage: http://search.cpan.org/~olaf/Net-DNS-0.65/lib/Net/DNS.pm#EXAMPLES Just change: my $res = Net::DNS::Resolver-new; to: my $res = Net::DNS::Resolver-new(nameservers=[$nameserver]) or die; where $nameserver is the IP address of your name server. Rafał Pocztarski ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Resolve hostname by specified nameserver
my $res = Net::DNS::Resolver-new(nameservers=[$nameserver]) or die; Sorry, I overlooked the part where you wrote that you can't use Net::DNS... Just ignore my message. Rafał Pocztarski ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Resolve hostname by specified nameserver
rocku wrote: I am aware about Net::DNS, but unfortunately I cannot use it because it's not standard in ActivePerl 5.10. Is there any reason not to run ppm install Net::DNS to install it? -- Serguei Trouchelle ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs