Hi Perl Monks,
I am working on a client network and facing weird problem in one of the unix box. ****************************************************************
sub resolve($) { my($packed_ip)=@_; my $ip_address='n/a'; if (defined $packed_ip) { $ip_address=inet_ntoa($packed_ip); } return($ip_address); } sub main() { my $packed_ip = gethostbyname("web99.mytest.in.client.com"); my $resolved=resolve($packed_ip); print("web99.mytest.in.client.com: ".$resolved."\n\n"); my $packed_ip1 = gethostbyname("web99"); $resolved=resolve($packed_ip1); print("web99: ".$resolved."\n"); } main();

And we got the following results,
web99.mytest.in.client.com: 141.168.243.250
web99: 10.97.225.188

But in the /etc/hosts file, it has the following line,
141.168.243.250 web99.mytest.in.client.com web99
However, if we execute nslookup on this box, it will show
web97 $ nslookup web99 Server: 144.136.201.10 Address: 144.136.201.10#53 Non-authoritative answer: Name: web99.ebr.in.client.com Address: 10.97.225.188 web97 $ nslookup web99.mytest.in.client.com Server: 144.136.201.10 Address: 144.136.201.10#53 Non-authoritative answer: Name: web99.mytest.in.client.com Address: 141.168.243.250
cheers
Rock

In reply to gethostbyname() problem by rockmountain

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.