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

Hello, I have trouble getting the Perl DNS Resolver Module working. I'm using it in sa-update (for updating spamassassin rules). This is the error I get in the log file:
warn: Error creating a DNS resolver socket: No such file or directory + at /opt/lib/perl5/site_perl/5.8.8/Mail/SpamAssassin/DnsResolver.pm l +ine 203
The DnsResolver.pm-file is present, and the code that generates the error message is here:
my $port_offset = int(rand(64511)); # 65535 - 1024 for (my $i = 0; $i<64511; $i++) { my $lport = 1024 + (($port_offset + $i) % 64511); my %args = ( PeerAddr => $ns, PeerPort => $self->{res}->{port}, Proto => 'udp', LocalPort => $lport, Type => SOCK_DGRAM, Domain => $family, ); if (HAS_SOCKET_INET6) { $sock = IO::Socket::INET6->new(%args); } else { $sock = IO::Socket::INET->new(%args); } $errno = $!; if (defined $sock) { # ok, got it last; } elsif ($! == EADDRINUSE) { # in use, let's try another source p +ort dbg("dns: UDP port $lport already in use, trying another port"); } else { # did we fail due to the attempted use of an IPv6 nameserver? $self->_ipv6_ns_warning() if (!$ipv6 && $errno==EINVAL); warn "Error creating a DNS resolver socket: $errno"; goto no_sock; } } if (!defined $sock) { warn "Can't create a DNS resolver socket: $errno"; goto no_sock; }
If I run "print $res->string;", I get this output:
;; RESOLVER state: ;; domain = ;; searchlist = ;; nameservers = <DNS IP's protected) ;; port = 53 ;; srcport = 0 ;; srcaddr = 0.0.0.0 ;; tcp_timeout = 120 ;; retrans = 5 retry = 4 ;; usevc = 0 stayopen = 0 igntc = 0 ;; defnames = 1 dnsrch = 1 ;; recurse = 1 debug = 0
If I run a "dnstracer"-command I get reply, so it seems to be Perl-related. Any ideas? Thanks, Ibux

Replies are listed 'Best First'.
Re: Error creating a DNS resolver socket
by Anonymous Monk on Aug 22, 2008 at 07:05 UTC
    strace/ktrace it, you'll probably find /etc/protocols is inaccessible (you're probably in a chroot jail)
      You're absolutely right. I created the /etc/protocols in the chrooted environment, and it worked like a charm. Thanks a lot!