Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nsswitch.conf being ignored

444 views
Skip to first unread message

Colin B.

unread,
Sep 26, 2012, 5:11:05 PM9/26/12
to
Hey all;

Got a weird problem where DNS is properly set up and works fine using
dig, hosts, or nslookup; but gethostbyname(3) is NOT using it.

/etc/nsswitch.conf is set up properly: (hosts: files dns)
/etc/host.conf appears fine too. (order hosts,bind)

But when I do getent hosts <FQDN> or plug an FQDN into an application
config file, it stops after trying the /etc/host file.

Any ideas? This is not normal behaviour!

Thanks,
Colin

Trevor Hemsley

unread,
Sep 26, 2012, 7:26:41 PM9/26/12
to
What are the permissions on /etc/nsswitch.conf? Should be 644.


--
Trevor Hemsley, Brighton, UK
Trevor dot Hemsley at ntlworld dot com

GangGreene

unread,
Sep 26, 2012, 7:50:34 PM9/26/12
to
Does it return right away or does it "timeout"?

Is /etc/resolv.conf correct?

Colin B.

unread,
Sep 27, 2012, 3:15:02 PM9/27/12
to
Trevor Hemsley <Trevor....@mytrousers.ntlworld.com> wrote:
> On Wed, 26 Sep 2012 21:11:05 UTC in comp.os.linux.setup, "Colin B."
> <cbi...@somewhereelse.shaw.ca> wrote:
>
>> Hey all;
>>
>> Got a weird problem where DNS is properly set up and works fine using
>> dig, hosts, or nslookup; but gethostbyname(3) is NOT using it.
>>
>> /etc/nsswitch.conf is set up properly: (hosts: files dns)
>> /etc/host.conf appears fine too. (order hosts,bind)
>>
>> But when I do getent hosts <FQDN> or plug an FQDN into an application
>> config file, it stops after trying the /etc/host file.
>>
>> Any ideas? This is not normal behaviour!
>
> What are the permissions on /etc/nsswitch.conf? Should be 644.

Found the problem.

Permissions were correct, the file was not.

There was a space in front of each nameserver line in /etc/resolv.conf:

nameserver 1.2.3.4
nameserver 2.3.4.5

Apparently the resolver code for dig and nslookup can parse this space,
but the system resolver libraries cannot.

For what it's worth, this is an issue in CentOS 5.2 and 6.3 both, so I
would imagine at least everything between them.

Cheers folks!
Colin

0 new messages