trying to determine gethostbyaddr call issues doesnt appear to be dns related

J

j.greg.k

I have checked the dns ptr records for the example below and the
records exists. also when doing an nslookup from the console on the
system in which perl is installed I get the correct name

$ nslookup a.b.c.d
Server: a.b.c.2
Address: a.b.c.2#53

d.c.b.a.in-addr.arpa name = ccc_dddd_ddddddd_ddd_cc.dom.ain.

Where c = character and d = digit. It's a common naming convention we
use on our internal dns servers:
building_model_serialtag_other-tag_type

I am not allowed to post the ip address or name but since it is
internal and the world cannot resolve the address anyhow it would not
do much good even if I could.

Next is the output when I run the perl program

$ ./hostname.pl
SUB:GETHOSTNAME: Got ccc_dddd_ddddddd_ddd

It truncates the last _ccc for some reason. Here is the code. It works
for all but the cases above in which the last few characters are _sw
and the length of the return value is at or more than 20 places ( I
have about 5 cases so far out of 1200 nodes)



#!/usr/bin/perl
use Socket;
#####################################
# Sub: GetHostname
#####################################
sub gethostname
{
my $target = shift;
$dname = gethostbyaddr(inet_aton($target),AF_INET) or $dname =
'noresolve';
print " SUB:GETHOSTNAME: Got $dname\n";
}

my $target = 'a.b.c.d';
gethostname ($target);

I am running this on an intel system RHES 4
perl -v
This is perl, v5.8.5 built for i386-linux-thread-mult



any ideas?
 
M

Manish

I have checked the dns ptr records for the example below and the
records exists. also when doing an nslookup from the console on the
system in which perl is installed I get the correct name

$ nslookup a.b.c.d
Server: a.b.c.2
Address: a.b.c.2#53

d.c.b.a.in-addr.arpa name = ccc_dddd_ddddddd_ddd_cc.dom.ain.

Where c = character and d = digit. It's a common naming convention we
use on our internal dns servers:
building_model_serialtag_other-tag_type

I am not allowed to post the ip address or name but since it is
internal and the world cannot resolve the address anyhow it would not
do much good even if I could.

Next is the output when I run the perl program

$ ./hostname.pl
SUB:GETHOSTNAME: Got ccc_dddd_ddddddd_ddd

It truncates the last _ccc for some reason. Here is the code. It works
for all but the cases above in which the last few characters are _sw
and the length of the return value is at or more than 20 places ( I
have about 5 cases so far out of 1200 nodes)

#!/usr/bin/perl
use Socket;
#####################################
# Sub: GetHostname
#####################################
sub gethostname
{
my $target = shift;
$dname = gethostbyaddr(inet_aton($target),AF_INET) or $dname =
'noresolve';
print " SUB:GETHOSTNAME: Got $dname\n";

}

my $target = 'a.b.c.d';
gethostname ($target);

I am running this on an intel system RHES 4
perl -v
This is perl, v5.8.5 built for i386-linux-thread-mult

any ideas?

Your code doesnot masks anything. I have tried using a global address
such as www.yahoo.com, I don't see the problem you described. Perhaps
you can try to use some other IP address, and provide us the sample
problem.

Regards,
Manish
 
J

J. Gleixner

sub gethostname
{
my $target = shift;
$dname = gethostbyaddr(inet_aton($target),AF_INET) or $dname =
'noresolve';

my $dname = gethostbyaddr(inet_aton($target),AF_INET) || 'noresolve';

That probably doesn't fix anything, but it should be corrected.
 
P

Peter J. Holzer

I have checked the dns ptr records for the example below and the
records exists. also when doing an nslookup from the console on the
system in which perl is installed I get the correct name

$ nslookup a.b.c.d [...]
d.c.b.a.in-addr.arpa name = ccc_dddd_ddddddd_ddd_cc.dom.ain.

Where c = character and d = digit. It's a common naming convention we
use on our internal dns servers:
building_model_serialtag_other-tag_type

Underscores aren't allowed in host names, but that shouldn't matter.
Next is the output when I run the perl program

$ ./hostname.pl
SUB:GETHOSTNAME: Got ccc_dddd_ddddddd_ddd

It truncates the last _ccc for some reason.

It also truncates the domain name, which it shouldn't do.

This makes me wonder whether gethostbyaddr gets the information from
DNS at all. Check if there is a local /etc/hosts file with the affected
ip addresses. If that's not the case check /etc/nsswitch.conf, whether
there are any other datasources except "files" and "dns" for "hosts".

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top