Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to ge the header information(os,cpu) of a DNS. Came across Net::DNS::RR::HINFO, but dont know.. how to use it. Please help, giving some example.

Replies are listed 'Best First'.
Re: header information of a DNS
by sunadmn (Curate) on Mar 01, 2004 at 13:18 UTC
    First I would like to suggest that you first post some sort of code so we may look at what you have thus far and then we may guide you in the correct direction. Secondly this is a place of learning and not a place to get your job done. Yes we are here to help you out but dont expect the Monks to finish your work for you we are more guides than anything and will help in anyway possible, but dont expect this to be a place you can just run to and get a finished product. Thirdly I would suggest taking a look at the PerlDoc for the mod, most every mod author puts examples in the docs this is always the first place to start at and once you have some sort of work done from the example then post the code with a question and we can then take a deeper look into your issue and help guide you in the correct direction.
    perldoc Net::DNS::RR:HINFO should get you to the example code you need ok.

    SUNADMN
    USE PERL
Re: header information of a DNS
by Fletch (Bishop) on Mar 01, 2004 at 15:59 UTC

    Not to mention pretty much nobody provides host info records (or at least correct host info) since it tells potential black hats useful information about a box they'd need to know to do something nefarious.

Re: header information of a DNS
by iburrell (Chaplain) on Mar 01, 2004 at 21:21 UTC
    What do you mean by header information? HINFO records are host information; they hold the os and cpu for hosts. The Net::DNS::RR::HINFO objects holds the data. You need to read the Net::DNS documentation on how to do DNS queries.
    my $res = Net::DNS::Resolver->new(); my $packet = $res->search('example.com', 'HINFO'); my ($rr) = $packet->answer(); print "cpu = ", $rr->cpu, " os = ", $rr->os, "\n";
    Very few public domains on the Internet use HINFO records. Some internal domains do contain host info, but only if added explicitly by the administrator.
      When iam using this code use Net::DNS::Resolver; my $res = Net::DNS::Resolver->new(); my $packet = $res->search('www.indiaimage.nic.in', 'HINFO'); my ($rr) = $packet->answer(); print "cpu = ", $rr->cpu, " os = ", $rr->os, "\n"; Iam getting error: Can't call method "answer" on an undefined value at hinfo.pl line 4. My requiement is that If i give any hostname i have to get remote O.S. used by that host.
        You will need to check the Net::DNS documentation to find out what happens when the query fails or is not found. My guess is that the record is not found. You will need to check for this.

        This is not surprising since HINFO records are rare. Unless you know that that domain defines them, doing the query is not going to useful.