| Lesson 3 || Name service and the resolver |
| Objective || nsswitch.conf file uses to convert host names to IP addresses |
Linux Name Service Resolver
The Linux Name Service Resolver (also known as the DNS resolver) is a component of the Linux operating system that is responsible for translating human-readable domain names (such as www.dispersednet.com) into IP addresses that computers can understand.
When you type a domain name into a web browser or a command line tool, the resolver looks up the IP address associated with that domain name by querying a series of DNS servers. The resolver caches the results of these queries so that subsequent requests for the same domain name can be resolved more quickly.
The Linux Name Service Resolver is used by a wide variety of applications and services on Linux systems, including web browsers, email clients, and command line tools. It is an essential component of the networking infrastructure of a Linux system, allowing users and applications to communicate with other computers and servers on the internet using domain names rather than numerical IP addresses.
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
to open a telnet 
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
to a numeric IP address.
The resolver library may do this in one of three ways:
- Look up the IP address using a local database file (/etc/hosts)
- 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)
- Look up the IP address using the Domain Name Service
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
A TCP/IP application that is used for remote terminal access and can be used to administer a UNIX machine.