Operating System - HP-UX
1834877 Members
2425 Online
110070 Solutions
New Discussion

Re: nsswitch file usage question

 
SOLVED
Go to solution
Manuel G
Frequent Advisor

nsswitch file usage question

Hi all:

We??ve got some systems with nsswitch file on /etc and few more without it.

On the first group, if we delete nsswitch file, system works with some problems, slow telnet connections, CDE environment fails, slow Oracle responses, etc...

On the second group, all systems works fine without nsswitch.

Can anyone explain what??s the purpose of such file and why is needed on some systems and not in others?

Thanks in advance.
9 REPLIES 9
harry d brown jr
Honored Contributor

Re: nsswitch file usage question

What does your /etc/resolv.conf file's look like.

live free or die
harry
Live Free or Die
Craig Rants
Honored Contributor

Re: nsswitch file usage question

The nsswitch file is important for cycling through the possible sources of host to ip information.

If a nsswitch file is setup to look at the hosts file and then quit if it does not find an answer, you will never touch a DNS server. That is why the nsswitch file is important.

Post the contents of that file as well as the resolv.conf like Harry asked for.

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Uday_S_Ankolekar
Honored Contributor

Re: nsswitch file usage question

If nsswitch file on some hosts
works fine : check the method of hosts resolution
it should be something like hosts: files [NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=continue

This would typically tell you how hostname get resolved , First it looks for /etchosts file thne if it didnot find entry in hosts look for DNS .

Second you can look for /etc/resolv.conf file and check for search order and domain name.
Do you have DNS running in your env..??

-USA..
Good Luck..
Ralph Grothe
Honored Contributor

Re: nsswitch file usage question

The nsswitch.conf is a creation by SUN Microsystems
(you remember those who came up with the yellow pages, what later turned into NIS => NIS+ owe to legal issues with British Telecom)
There should be a nice manpage installed on your system that explains its purpose well.
Although generally for many name services (e.g. DNS, NIS, LDAP?) it is also used (if present) by the resolver to decide the order in which to query either your DNS server or /etc/hosts.
To speed things up Files should be first (but only list loopback, hostname, node names of peer SG cluster nodes, and package names in /etc/hosts, nothing more), then let it query your DNS server.
Otherwise you can get nasty timeouts especially when DNS is not available.
The firewallers occasionally (unitentionally?) drop packets for port 53 ;-)
The syntax iof /etc/nsswitch.conf s thoroughly explained in the mentioned manpage.
type
man nsswitch.conf
Madness, thy name is system administration
Manuel G
Frequent Advisor

Re: nsswitch file usage question

/etc/resolv.conf:
domain enyca.es
nameserver 192.168.1.100

/etc/nsswitch:
#
# /etc/nsswitch.conf
#
# This is the default configuration file for the name service switch.
# It will cause behavior similar to that performed on prior HP-UX
# releases when a configurable name service algorithm was not provided.
#
# If the /etc/nsswitch.conf file is not present, it will default to the
# behavior represented by the ordering and conditions below.
#
# See the Adminstering Internet Services Manual and the switch(4) man
# page for more information on the name service switch.
#

group: files nis dns
passwd: files[NOTFOUND=continue UNAVAIL=continue] nis [NOTFOUND=return UNAVAIL=continue TRAYAGAIN=return]
hosts: files [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=return] dns [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=return] nis
services: nis [NOTFOUND=return UNAVAIL=continue] files
networks: nis [NOTFOUND=return UNAVAIL=continue] files
aliases: dns
netgroup: nis [NOTFOUND=return UNAVAIL=continue] files
rpc: nis [NOTFOUND=return UNAVAIL=continue] files
protocols: nis [NOTFOUND=return UNAVAIL=continue] files
passwd: files
group: files
Darrell Allen
Honored Contributor
Solution

Re: nsswitch file usage question

Hi,

First, see man nsswitch.conf. It's got some good info.

There are a number of "databases" which are used (or could possibly be used) by the system. They contain information about hostnames, IP addresses, users, and a number of others. nsswitch.conf is used to specify which databases are searched and in what order.

For example, hostname to IP address resolution can be performed using /etc/hosts, DNS, NIS, or NIS+. If you don't use some of these, you shouldn't have them in nsswitch.conf.

According to the man page, by default, the OS uses the following to resolve IP addresses and hostnames:
hosts: nis [NOTFOUND=return] files
If nis is not in use, /etc/hosts will be checked (files means to use the standard configuration file on the local host). If nis is configured and nis does not find the entry being resolved, then resolution ends without consulting /etc/hosts.

So, from the info in the man page it can be determince that the system will work fine without nsswitch.conf IF nis is not used and the local configuration files contain all the info needed.

If you use NIS, NIS+, or DNS, you should create nsswitch.conf and modify it to suit your purposes. At the least, if using nis, you probably need to change [NOTFOUND=return] to [NOTFOUND=continue]. Alternatively, you may want to change the order so that files is before nis.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Craig Rants
Honored Contributor

Re: nsswitch file usage question

How about trying a simple first line like:

hosts: files [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue] dns

See what happens.

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Roger Baptiste
Honored Contributor

Re: nsswitch file usage question

hi,

For a system which is self-contained, i.e. it is not a part of NIS or depends on system info from other systems , there would be no necessity for nsswitch.conf. But, most of the
unix systems out there are not stand-alone
pieces, so by default we have nsswitch.conf file to help the system routines know where it has to pick specific objects from.
for instance:
hosts -> this entry instructs where to look for host<->ip information from : DNS server, or local /etc/hosts file.

So each entry has a meaning. There are different versions of nsswitch.conf file based on the system you have. Look at
#ll /etc/nsswitch*
-r--r--r-- 1 bin bin 528 Nov 6 1997 /etc/nsswitch.compat
-r--r--r-- 1 root sys 377 Jan 5 2001 /etc/nsswitch.conf
-r--r--r-- 1 root sys 377 Jan 5 2001 /etc/nsswitch.conf.20010105
-r--r--r-- 1 bin bin 353 Nov 6 1997 /etc/nsswitch.files
-r--r--r-- 1 bin bin 555 Nov 6 1997 /etc/nsswitch.hp_defaults
-r--r--r-- 1 bin bin 513 Nov 6 1997 /etc/nsswitch.nis
-r--r--r-- 1 bin bin 566 Nov 6 1997 /etc/nsswitch.nisplus

There are different versions for nisplus systems, nis system , plain(files)system.
Based on the system you have, you just have to copy the file to /etc/nsswitch.conf

HTH
raj
Take it easy.