The etcnsswitch.conf File

Shut down one more slave server and recreate for the new NIS domain. • Switch another 20 of clients to the new NIS domain. • Repeat the procedure for remaining slave servers and clients. • At the end, the old domain name is purged and the new domain name activated.

17.4 NIS vs. DNS

The domain name system DNS is the dedicated global service that spans the entire Internet with only one goal — to provide information about hosts worldwide; to be more specific, to provide host names and IP addresses. DNS is fully discussed in Chapter 16. The Network Information Service NIS is a dedicated service to provide various administrative data for a certain number of hosts contained within the specified NIS domain; these data also include host names and IP addresses. Obviously DNS and NIS overlap in this sphere — host names and IP addresses for the related hosts could be managed from both places. The logical question is, can NIS and DNS coexist peacefully? The answer is definitely yes, but it requires additional administration. Having in mind that the local etchosts files provide also the data about host names and IP addresses, we come to the three independent sources for the same data. Who has priority? How is data synchronized? What do you do if the same data are inconsistent? These are only few of the potential problems that we have to handle.

17.4.1 The etcnsswitch.conf File

Modern UNIX flavors, like Solaris, HP−UX, or Linux, provide a special name−service−switch configuration file etcnsswitch.conf, which specifies the lookup policy used to define the order and the conditions under which various sources are queried to obtain the desired information. The lookup policy is defined by an nsswitch−entry specified by the system administrator; this is a text line with an understandable syntax. The following sources databases are allowed to be used in the specified policy: dns domain name system, nis Network Information Service, and files local configuration files. An nsswitch−entry must be on a single line, and includes: info−class: src [ criteria src [ criteria src ] ] where info−class Refers to the class of information being queried: for example, hosts for the host name service resolution. src Refers to a source network database to be queried, as stated earlier dns, nis, and files. criteria Optional field containing status=action pairs enclosed in square brackets, which represent the criteria when, and how, to query the following source. The valid status strings are: SUCCESS, NOTFOUND, TRYAGAIN, and UNAVAIL. The valid action strings are: continue and return — to continue query with the next source on the line if the associated status for this action has occurred, or to terminate the search and return any result of the last query. Default actions are: 423 For NOTFOUND=return • For UNAVAIL=continue • for TRYAGAIN=return • The only exception is that all the actions associated with the last source in the entry are always set to return and cannot be overridden. The following example from HP−UX 10.20 illustrates the different policies for querying hostname resolution: cat etcnsswitch.conf This file contains different configurations to query hostname resolution. Comment and comment−out corresponding entries that match the required policy. To use DNS first then etchosts, if DNS is either not up and running, or does not contain any answer in its database hosts: dns [NOTFOUND=continue] files To use etchosts first then DNS, if etchosts does not contain any answer in its database hosts: files [NOTFOUND=continue] dns To use NIS first then etchosts, if NIS is either not up and running, or does not contain any answer in its database hosts: nis [NOTFOUND=continue] files See the Administering Internet Services Manual and the switch4 man page for more information on the name service switch. The origin name of this file is related to the host name resolution; thus the ns prefix in the file name stands for the name service. However, only one nsswitch−entry in the file strictly addresses this issue; other entries are related to other network services and arbitrate between NIS and local databases for the corresponding service, like in the following example on the Linux platform: cat etcnsswitch.conf etcnsswitch.conf An example Name Service Switch config file. This file shoul be sorted with the most−used services at the beginning. The entry [NOTFOUND=return] means that the search for an entry should stop if the search in the previous entry turned up nothing. Note that if the search failed due to some other reason like no NIS server responding then the search continues with the next entry. Legal entries are: nisplus or nis+ Use NIS+ NIS version 3 nis or yp Use NIS NIS version 2, also called YP dns Use DNS Domain Name Service files Use the local files [NOTFOUND=return] Stop searching if not found so far Example – obey only what nisplus tells us… services: nisplus [NOTFOUND=return] files networks: nisplus [NOTFOUND=return] files protocols: nisplus [NOTFOUND=return] files passwd: files nis shadow: files nis 424 hosts: files dns bootparams: files ethers: files netmasks: files networks: files protocols: files rpc: files services: files automount: files aliases: files netgroup: nis Obviously this host is an NIS client. However NIS is not used for host name resolution. The presented configuration is very common for NIS clients and it includes a number of other configuration data.

17.4.2 Once upon a Time