« Return to Thread: How do I make Net::DNS::Resolver take /etc/hosts into account?

Re: How do I make Net::DNS::Resolver take /etc/hosts into account?

by Henrik K :: Rate this Message:

Reply to Author | View in Thread

On Thu, Jul 02, 2009 at 09:10:54AM +0200, Per Jessen wrote:

> René Berber wrote:
>
> > On many operating systems (Solaris, Fedora 11, and Gentoo Linux are
> > the ones I have) the file /etc/nsswitch.conf controls exactly what you
> > are asking, the usual relevant line is:
> >
> > hosts:       files dns
> >
> > Which means first look at /etc/hosts, then ask bind (named).
> >
> > In Fedora 11 the same line is more complex, returning an error before
> > using named, but that is not your problem:
> >
> > hosts:       files mdns4_minimal [NOTFOUND=return] dns
>
> Rene, that's not the issue here at all.
>
> Here it is in a nutshell:
>
> 1) a tiny perl test-script using gethostbyname() will look at /etc/hosts
> and try to resolve the name from there. Works fine and just as
> expected.
>
> 2) a call to gethostbyname() from within an SA plugin does NOT look
> at /etc/hosts.  

Please share your code so we can verify and test it. There is nothing in SA
code that would redefine gethostbyname.

 « Return to Thread: How do I make Net::DNS::Resolver take /etc/hosts into account?