-->
Previous | Table of Contents | Next |
Setting up an NIS master is usually straightforward. Begin by verifying the existing files on the master machine, such as /etc/passwd and /etc/group, to ensure the information is accurate and current. You should remove any expired or unwanted accounts, for example, and verify that all the login directories and commands are correct. While you are examining the /etc/passwd file, check to make sure that all accounts have passwords. If they dont, either assign a password or remove the account. With a network-wide NIS system in place, anyone can exploit these security holes to gain access to any machine on the network, including the NIS master and gateways machines.
After the files are ready for NIS map generation, make sure you are logged in as root, in order to set the proper ownerships and ensure full access to the filesystem. The NIS maps are generated from the standard UNIX files using the ypinit command with the -m option. The -m option indicates that this machine will be the NIS master. From the root prompt, issue the following command:
/usr/sbin/ypinit -m
The path to the ypinit program may be different on your UNIX system. Check the path if the command produces an error message when trying to execute.
When the ypinit command executes, it scans all the NIS files named in the file /var/yp and produces the NIS maps that are used by the client processes. The /var/yp file may have a different directory name on some systems, such as SCO UNIX, which uses /etc/yp as a directory for all NIS files. Check your UNIX system documentation or man pages for proper file locations. The /var/yp file contains a list of all the maps to be generated, and you will usually not have to make any changes at all to this file.
A new directory (usually called /var/yp/domainname, where domainname is the NIS domain name) is created. The maps are placed in this new domain name. If you are setting up more than one domain all handled by the same NIS master machine, the maps for each domain will be beneath the domain names subdirectory.
As the last step in ypinit, you are asked which machines are NIS slave servers, at which point you should enter their names. The slave names are saved in a file in the domain directory.
Tip:
On some versions of Linux, the NIS utilities are not in the same directories mentioned throughout this chapter. A few versions move them to other locations. To verify the proper locations, use the find command with the program name.
After the maps have been generated properly, you can start the ypserv daemon. It is best to automate the startup by editing the startup rc files to do this for you when the machine boots. There is a section in an rc file (usually the one that starts RPC) that looks like this:
if [ -f /etc/yp/ypserv -a -d /var/yp/domainname ] then /etc/yp/ypserv fi
This script checks for the existence of the directory /var/yp/domainname, where domainname is the domain name for your NIS domain. The entry on the first line where domainname is located must be in single back quotes, which means the shell should execute the domainname command and use the results. If the directory exists, the ypserv daemon is started. You should replace the directory paths with those used by your UNIX system.
To manually start the ypserv daemon, log in as root and issue the following command, or whatever the path to your ypserv daemon is
/etc/yp/ypserv
Next, you need to start the ypbind daemon on the server too (otherwise ypserv cant find the maps). Again, this is usually done through the rc startup scripts with an entry like this:
if [ -d /var/yp ] then /etc/yp/ypbind fi
Again, you should check that the directory path is correct. You can start the ypbind daemon manually by issuing it on the command line when logged in as root. Make sure the directory path is correct when you do so.
If you want to perform a quick test of the NIS daemons, issue a command like this one at the command line:
ypmatch tparker passwd
The ypmatch command asks NIS to use the maps to match up the next argument with the map of the third arguments name. In this example, ypmatch is instructed to look in the passwd file (passwd is the alias to passwd.byname) for the entry for tparker. You should get back the line that matches. Use any combination of map alias and entry you know exists in order to test the NIS server daemon.
In order to set up an NIS slave, the NIS master must be configured and running. When you are sure the master is operational, log in as root to the machine to be set up as the NIS slave. The domain name of the slave must be properly set before the configuration can proceed, so check the startup rc commands for the entry that sets the domainname variable or use the domainname command to set the domain name.
To set up the NIS slave and propagate the NIS files from the master to the slave, issue the following command, substituting for whatever path is correct on your system:
/etc/yp/ypbind
Check that the binding to the master is correct by issuing the ypwhich command. It should return the NIS master name.
Finally, issue this command, where the path is correct and servername is the name of your NIS master:
/etc/yp/ypinit -s servername
The ypbind -s option sets the local machine up as a slave. The ypbind command sets up directories on the local machine and transfers all the maps from the master to the slave.
After the setup is complete, you can test the slave setup with the ypmatch command as shown in the previous section.
To update the maps on the slaves at regular intervals, the ypxfer command is used on the slave, followed by the name of the map to be transferred. For example, this command transfers the passwd.byname file from the master to the slave:
ypxfer passwd.byname
Most administrators either create a set of cron entries for transferring all the NIS files at regular intervals (such as nightly) or use a script file executed by a network adminis-trator.
Previous | Table of Contents | Next |