NIS Client Networking  «Prev  Next»
Lesson 4/etc/nsswitch.conf
ObjectiveDescribe the Function and Purpose of nsswitch.conf

Function and Purpose of nsswitch.conf

The Network Services switch file /etc/nsswitch.conf determines the order of look-ups performed when a certain piece of information is requested.
You can choose the order of the look-ups. For example, you can configure Linux to resolve hostnames by first checking local files, then NIS, and finally DNS. Other information maps hold user and password information.

nsswitch.conf elements

In the nsswitch.conf file, lines beginning with a # are comments.
Every other non-blank line determines the look-up order for a particular type of information. To see explanations for a typical command line, roll your mouse over each term in the MouseOver below.

  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.

Typical nsswitch.conf line

Controlling look-ups

You can control the behavior of information look-ups further with a line in nsswitch.conf like the following:
hosts: nis [notfound=return] files dns

The [notfound=return] controls the use of look-up methods such as NIS. It tells Linux that if NIS is working, but the requested host is not found, it should skip the local files as well as DNS and return an error. On the other hand, if the NIS server simply does not respond, Linux proceeds to check the local files and then DNS.
See the nsswitch.conf man page for detailed information on available databases and look-up methods.
The next lesson shows you how to use authconfig to configure an NIS client machine.

nsswitch Function Elements

Before moving on to the next lesson, click the link below to practice matching the nsswitch elements to their functions.
nsswitch Function Elements