[NBLUG/talk] Firewall killing gethostbyname()?

Daniel Smith linux2002 at daniel.org
Sat Sep 13 14:15:01 PDT 2003


Hey programmers,

I'm in the midst of investigating why a gethostbyname()
call is failing in perl.  I notice the same failure
when I run hostname:

bucky:home/dls # hostname -v -i
gethostname()=`bucky'
Resolving `bucky' ...
hostname: Unknown host

I strongly suspect it is something that happened when
I set up my firewall with Bastille (though this was
a while back, and I am reluctant to fiddle with the
firewall) - my test script works fine on my home debian
box, and Mac OS X.

* does this sound familiar?
* what is a good plan B to get the IP addr in Perl for the
   local machine?

Even if I change my firewall, the script will be part of a
package that I Open Source, so I can't just assume that
others won't run into the problem (hence the need for a
Plan B).

Daniel

trivial test script:
#!/usr/bin/perl -w
use Socket;
use Sys::Hostname;
my $host = hostname();
my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
print <<EOM;
host is $host
addr is $addr
EOM


-- 
Daniel L. Smith - Sonoma County, CA - AIM: SonomaDaniel
daniel.org     blog: JavaJoint.com    resume.daniel.org



More information about the talk mailing list