DistributedNetworks DistributedNetworks


TCP/IP Configuration  « Prev  Next»
Lesson 3 Name service and the resolver
Objective nsswitch.conf file uses to convert host names to IP addresses

Linux Name Service Resolver

Examine the nsswitch.conf file, which the system uses to convert host names to IP addresses and back.
Name service allows a system to convert host names to IP addresses and back. Name service comes into play, for example, when a user types telnet www.acmecorp.com to open a telnet [1] connection. At this point, the telnet program makes a system call to the resolver library.
The resolver library is a package of subroutines, usually implemented as a shared-object library, that convert host names to IP addresses. In our example, the resolver library converts www.acmecorp.com to a numeric IP address.

Resolver Library

The resolver library may do this in one of three ways:
  1. Look up the IP address using a local database file (/etc/hosts)
  2. Look up the IP address using a local-network Network Information Database (NIS, NIS+) (The Network Information Database is covered in detail in the next course in this series, Linux/UNIX Network Administration II)
  3. Look up the IP address using the Domain Name Service

Getent

The /usr/bin/getent command will display a list of entries, Get Entries. The entries are resolved by Name Service Switch Libraries, which are configured in the /etc/ nsswitch.conf file. This file has a list of databases and libraries that will be used to access those databases.
For example, we could use the getent passwd command to display all users, or getent group to display all groups. We could extend this though to commands such as getent hosts to display host file entries and getent aliases to display user aliases on the system. The nsswitch.conf file will define the libraries used to access the passwd database. On a standard CentOS system, /etc/passwd is often the only local file, but an enterprise system could include Lightweight Directory Access Protocol (LDAP) modules. In the next chapter, we will learn more using directory services. We search the /etc/nsswitch file for the passwd database using grep:
# grep passwd /etc/nsswitch.conf

The getent command is a very useful way to quickly list users or groups on your system, and the output can be filtered or sorted as required with the grep and sort commands. For example, if we want to see all configured groups on our system that start with the letter u and have only one additional character in their names, we can use the following command:

# getent group | grep 'u.:' | sort

Name Service - Quiz

Click the Quiz link below to take a short multiple-choice quiz on TCP/IP configuration.
Name Service - Quiz
[1] Telnet: A TCP/IP application that is used for remote terminal access and can be used to administer a UNIX machine.