NIS Client Networking  «Prev  Next»
Lesson 3 Obtaining Information about the Network
ObjectiveObtain Information about the Network

Obtaining Information about the Network

Using NIS, you can obtain information about your network and the hosts on it. There are five functions used with NIS, all of which begin with "yp". The following table below contains an explanations of each function.

yp functions: 1) ypbind, 2) ypcat, 3) ypwhich, 4) ypmatch, 5) yppoll

yp functions: 1) ypbind, 2) ypcat, 3) ypwhich, 4) ypmatch, 5) yppoll
yp functions: 1) ypbind, 2) ypcat, 3) ypwhich, 4) ypmatch, 5) yppoll

yp functions

Note: The yp function is rarely used today within the context of Red Hat Linux. An enhanced yp-tools package that provides an enhancement is now available for Red Hat Enterprise Linux 6.
yp functions: 1) ypbind, 2) ypcat, 3) ypwhich, 4) ypmatch, 5) yppoll
yp functions: 1) ypbind, 2) ypcat, 3) ypwhich, 4) ypmatch, 5) yppoll

Properly Configured NIS Setup

A properly configured NIS setup involves configuring at least one NIS server and one or more NIS clients. If your Red Hat Linux system is going to be part of anetwork with existing NIS servers, you only need to install and configure the client programs, ypbind, ypwhich, ypcat, yppoll, and ypmatch. The most important program is the NIS client daemon, ypbind. ypbind is usually started from the system's startup procedure. As soon as ypbind is running your system has become an NIS client. On the other hand, if your Red Hat Linux system is going to be part of a network that does not already have NIS servers in place, you need to configure at least one NIS server, which involves configuring the ypserv client daemon and identifying the files that NIS distributes to client programs and, optionally, to slave servers.

ypbind daemon

After you have succesfully compiled the software you are now ready to install it. A suitable place for the ypbind[1] daemon is the directory
/usr/sbin. 

Some people may tell you that you do not need ypbind on a system with NYS and this is incorrect. ypwhich and ypcat require the ypbind daemon. You must do this as root and the other binaries (ypwhich, ypcat, yppasswd, yppoll, ypmatch) should go in a directory accessible by all users, normally /usr/bin.
Newer ypbind versions have a configuration file called
 /etc/yp.conf.
You can hardcode a NIS server there. You will require this file for NYS.

ypserver 10.10.0.1
ypserver 10.0.100.8
ypserver 10.3.1.1

These functions are powerful diagnostic tools. You can use them to check network configuration and your computer's interface to the NIS system. The commands ypwhich and ypmatch retrieve information about NIS servers and the information they have available.

ypwhich

The ypwhich command prints the name of your NIS server by default. When you pass the name of a NIS database to ypwhich (for example, if you type ypwhich -m hosts), it responds with the name of the master NIS server for that class of information (in this example, hostnames). If you are using separate NIS servers for different information, or if you need to check your NIS server name configuration, use ypwhich.

ypmatch

ypmatch lists the values of certain keys[2] in a given database. For example, the command line ypmatch host1 host2 hosts will return the values of the host1 and host2 keys from the hosts database; the associated values are the IP addresses assigned to their interfaces.
The next lesson describes the function and purpose of nsswitch.conf.

NIS command Matching

Before moving on to the next lesson, view the paragraph below to read about the commonly used NIS commands and their functions.

Frequently used NIS Commands

In Red Hat Linux, NIS (Network Information System) is a client-server networking protocol used to manage user and group information across a network. The following are some of the frequently used NIS commands in Red Hat Linux:
  1. ypwhich: This command is used to determine which NIS server the client is currently connected to. The command can be used with the -m option to display the NIS domain name.
  2. ypdomainname: This command is used to display or set the NIS domain name for the client. If used without any arguments, the command displays the current NIS domain name. If used with a domain name as an argument, the command sets the NIS domain name.
  3. ypcat: This command is used to display the contents of a specific NIS database. For example, ypcat passwd will display the contents of the passwd database, which contains user account information.
  4. ypmatch: This command is used to display a specific entry in a NIS database. For example, ypmatch username passwd will display the entry for the specified user in the passwd database.
  5. ypwhich -s: This command is used to display a list of NIS servers that are currently available on the network.
  6. ypinit: This command is used to initialize an NIS server. It must be run on the server machine and will create the necessary NIS databases and configuration files.
  7. ypbind: This command is used to bind an NIS client to an NIS server. It must be run on the client machine and will allow the client to access NIS databases.
  8. yppasswd: This command is used to change the password for a user in the NIS database. It must be run on the NIS server machine and requires root privileges.

These commands are frequently used by system administrators to manage user and group information in NIS databases, bind NIS clients to NIS servers, and troubleshoot NIS-related issues.

Here is a list of commands commands with their corresponding definitions. Below are the results.
  1. yppoll: Returns the server name and NIS version for a given database
  2. ypmatch: Lists the values of keys within a database
  3. ypcat: Lists the entire contents of a given database
  4. ypwhich: Returns the name of the NIS server used, or the master server for a given database
  5. ypbind: The client-side NIS daemon

Network Information System Servers

Network Information System (NIS) is a software feature developed by Sun Microsystems to manage information needed to configure a group of UNIX (and now Linux) computers on a network. Using NIS, a group of computers can share common passwd, groups, hosts, and other configuration files. By default, NIS services are off. You can turn on NIS services for your Linux computer as either an NIS client (using shared information) or an NIS server (distributing shared information). NIS client computers need to start the /etc/init.d/ypbind script and identify the NIS servers in the /etc/yp.conf file. To use Fedora or RHEL as an NIS server, you must gather up the configuration files you want to share, then start the /etc/init.d/ypserv script. The script runs the /usr/sbin/ypserv daemon, which takes care of the distribution of information to the NIS client computers.

Configuring NIS Server daemons

The NIS server must be running several daemon processes to be an NIS server. Red Hat Linux supplies several run-level scripts that you can configure to start NIS server daemon processes. These scripts, located in the /etc/init.d directory, include the following:
  1. ypserv: This script starts the ypserv (/usr/sbin/ypserv) daemon. It reads information from the /etc/ypserv.conf file to determine what to do. Then it listens for requests from NIS client computers on the network.
  2. yppasswdd: This script starts the rpc.yppasswdd (/usr/sbin/rpc.yppasswdd) daemon. This daemon handles requests from users on NIS client computers who want to change their user passwords.

Unless you requested that these scripts be configured to start at boot-time when you installed Red Hat Linux, they will not start automatically. You can use the following chkconfig command to set ypserv and yppasswdd scripts to start automatically at boot time.
# chkconfig ypserv on
# chkconfig yppasswdd on

If you want to start the services immediately, you can type the following:
# /etc/init.d/ypserv start
# /etc/init.d/yppasswdd start

The NIS master server should be up and running. If there are any NIS slave servers, you should configure them now.
Before moving on to the next lesson, click the link below to complete the exercise on NIS commands and their functions.
Obtain Network Information - Exercise

[1]ypbind: Binds to an NIS (Network Information Service) master server (if NIS is configured), and starts or stops the ypbind process, which communicates with the master server.
[2]Key: In databases, a key is a parameter that holds a value. For example the value of hostname could be its IP address.