|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
NIS use client server architecture with one master server (and possibly one or several secondary slave servers, necessary for reliability) and many clients. NIS uses several daemons on the server and on all clients to enable the NIS system.
The binding process begins with ypbind sending out a broadcast message for any NIS masters on the network to respond with their IP address and the port number to send requests on. If more than one NIS master responds to the request, only the first received reply is used. If for some reason ypbind finds it isn't getting replies from the NIS master, it assumes that the master has crashed and retransmits a request for a master.
The main daemons involved in the running of an NIS domain are:
You can find out which NIS master any client machine is bound to with the command ypwhich
Note – Installations that select Core, End User, or Developer software configuration clusters do not have all of the necessary files in the /usr/lib/netsvc/yp directory to allow a host to function as an NIS server.
Configuring 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 that 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 don't, 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 gateway machines.
Then you need to delete all common user accounts and inset special line into the files to enable NIS include mechanism. Deletion might actually is not necessary if the insert directive is placed just after all system account.
Once the files are ready for NIS map generation, make sure you are logged in as root (to set the proper ownerships and ensure full access to the filesystem).
The initial set of NIS maps can be generated from the standard UNIX files, using the ypinit command with the -m option. The -m option indicates that this machine is the NIS master. From the root prompt, issue the following command:
/usr/sbin/ypinit -m
The path to the ypinit program might 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 might 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 usually you do not have to make any changes 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 directory. If you are Configuring more than one domain all handled by the same NIS master machine, the maps for each domain are beneath the domain name's 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.
After the maps have been generated properly, you can start the ypserv daemon and test the service. 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.
To manually start the ypserv daemon, log in as root and issue the command
/etc/yp/ypserv
or whatever the path to your ypserv daemon is.
Next, you need to start the ypbind daemon on the server, too (otherwise, ypserv can't 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 verify 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 joeuser passwd
The ypmatch command asks NIS to use the maps to match up the next argument with the map of the third argument's name. In this example, ypmatch is instructed to look in the passwd file (passwd is the alias to passwd.byname) for the entry for joseuser. You should get back the line that matches. You can use any combination of map alias and entry that you know exists to test the NIS server daemon.
To set up the NIS name service master server, perform the following steps:
# domainname domainname
For example:
# domainname classroom.central.sun.com
Note – You can also copy the network information files to some other location
on the system and modify them there rather than modifying them in the /etc
directory.
These files are necessary for the creation of the complete
set of NIS maps as directed in the Makefile file. When you initialize NIS, you
receive error messages for each of these files if they do not exist.
Note – The lab at the end of this module shows you how
to create the updated Makefile file.
domainname locale
For example:
classroom.central.sun.com en_us
ypinit -m
The following example shows the text feedback displayed as the program begins:
ypinit -m
In order for NIS to operate successfully, we have to construct a list of the NIS servers. Please continue to add the names for YP servers in order of preference, one per line. When you are done with the list, type a <control D> or a return on a line by itself.
next host to add: server1
The current list of yp servers looks like this:
next host to add: <Control-D>
server1
Is this correct? [y/n: y] y
Installing the YP database will require that you answer a few questions. Questions will all be asked at the beginning of the procedure.
Do you want this procedure to quit on non-fatal errors? [y/n: n] n
OK, please remember to go back and redo manually whatever fails. If you
don't, some part of the system (perhaps the yp itself) won't work.
Note – If you have to restart the ypinit program, you are prompted to
destroy the /var/yp/domainname
directory. Answer y.
A single NIS server may be a slave of more than one master server, if it is providing service to multiple domains. In addition, a server may be a master for one domain and a slave of another.
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 command
/etc/yp/ypbind
substituting for whatever path is correct on your system. Check that the binding to the master is correct by issuing the ypwhich command. It should return the NIS master name.
Finally, issue the command
/etc/yp/ypinit -s servername
where the path is correct and servername is the name of your NIS master. 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 ypxfr command is used on the slave, followed by the name of the map to be transferred. For example the command
ypxfer passwd.byname
transfers the passwd.byname file from the master to the slave. Most administrators create a set of cron entries for transferring all the NIS files at regular intervals (such as nightly). You can also use a script file executed by a network administrator.
You should have at least one NIS slave server to provide backup if the NIS master server becomes unavailable. To configure an NIS slave server, complete the following steps on the system that you want to designate as the slave server:
# domainname domainname
For example:
# domainname classroom.Central.Sun.COM
If it is not running, refer to the previous section on how to start NIS daemons on the master.
# /usr/lib/netsvc/yp/ypstart
# ypinit -s master where masteris the name of the NIS master.
Note – If you did not add the name of the NIS slave server when you initially configured the NIS master server using the ypinit command, enter the ypinit -m command once more on the NIS master server. In the process of updating the NIS master, the script prompts you for confirmation when it is about to destroy the existing domain database. Confirm by entering y.
# /usr/lib/netsvc/yp/ypstart
The output shows a list of maps together with the NIS master server for each map.
There are a number of commands that you can use to obtain information from and about the NIS database. You can also use these commands to test the functionality of the NIS service. You do not have to be the superuser to use these commands.
The most commonly used NIS commands are: ypcat, ypmatch, ypwhich.
ypmatch user5 passwd
$ ypwhich -m
...
<output truncated>
...
timezone.byname alpha
netmasks.byaddr alpha
netid.byname alpha
bootparams alpha
netgroup.byhost alpha
netgroup.byuser alpha
netgroup alpha
...
<output truncated>
...
All systems within an NIS domain that are not configured as servers are configured as clients. To configure the NIS client, complete the following steps:
# domainname classroom.central.sun.com
# ypinit -c
Note – To exit the ypinit command without building a specific list of NIS
servers, press Control-D.
The client then broadcasts to bind the first available
server during subsequent ypbind operations. When not operating in broadcast
mode, clients can only bind to servers that are listed in their /var/yp/binding/domainname/ypservers
file.
# /usr/lib/netsvc/yp/ypstart
# ypwhich -m
The output shows a list of maps together with the NIS master server for each map.
Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: February 28, 2008