NIS Client Networking  «Prev 

NIS /etc/nsswitch.conf line

A line in the /etc/nsswitch.conf file for NIS (Network Information Service) in Red Hat Linux consists of a keyword followed by one or more sources of information, separated by spaces or tabs. The keyword indicates which system entity the line refers to, such as "passwd" for user account information or "hosts" for network host information.
For example, a line in the /etc/nsswitch.conf file for NIS that specifies the order in which user account information should be searched might look like this:
passwd: files nis
This line tells the system to first look for user account information in the local files (e.g. /etc/passwd) and then in the NIS database. The order of the sources is significant, as the system will stop searching once it finds the requested information.
Other keywords that can appear in an NIS /etc/nsswitch.conf line include "group" for group information, "shadow" for password shadow information, and "netgroup" for network group information. The sources of information that can appear in the line depend on the keyword and the available NIS domains on the network. For example, a source for NIS user account information might be specified as "nis" or "nisplus" followed by the name of the NIS domain.

Using NIS maps

For the information being distributed by the NIS server to be used by the NIS client, you must configure the /etc/nsswitch.conf file to include nis in the search path for each file you want to use. The following is a listing from the /etc/nsswitch.conf file showing valid values that can be in the search paths for accessing different configuration files.

# 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
# db Use the local database (.db) files
# compat Use NIS on compat mode
# hesiod Use Hesiod for user lookups
# [NOTFOUND=return] Stop searching if not found so far

For our purposes, we want to add nis into the paths for the files we want to distribute from our NIS server to the NIS client. In most cases, the local files are checked first (files), followed by nisplus. The following are examples of how some entries appear:
passwd: files nisplus
shadow: files nisplus
group: files nisplus
hosts: files nisplus dns

For each of these entries, the original files are checked first (/etc/passwd, /etc/shadow, and so on). Then any nisplus server is checked. For host names, the DNS server is checked last. For our purposes, we can change nisplus to nis to access the maps being shared from the NIS server. The lines would then appear as follows:
passwd: files nis
shadow: files nis
group: files nis
hosts: files nis dns

As soon as the /etc/nsswitch file is changed, the data from the NIS maps are accessible. No need to restart the NIS service. You can now go through and change any of the files listed in the /etc/nsswitch file so that it is configured to let our system access the NIS maps being shared.
Red Hat Reference

Typical /etc/nsswitch.conf line for NIS

nsswitch.conf line for NIS
nsswitch.conf line for NIS

  1. Linux refers to this line when seeking information about hosts. Other information maps include password services and protocols
  2. On this particular network, Linux first checks the NIS server for hostname information
  3. If the NIS system fails to find the requested information, the local files are checked. In this case, Linux checks
  4. After NIS and local files have failed to return the sought for information, Linux checks the DNS system. If DNS fails, the user application that requested the information receives an error message.