Configuring the Network Infomation Service (NIS) (part4)
To set up the NIS name service master server, perform the following steps:
- Determine which machines on your network domain will be NIS servers. There should be one NIS master server, and there can be as many NIS slave servers as needed. All systems within the domain are NIS clients.
- Choose an NIS domain name. This is usually less than 32 characters in length. (The maximum length is 256 characters, and it is case sensitive.)
- Enter the domainname command to set the local NIS domain.
# domainname domainname
For example:
# domainname classroom.Central.Sun.COM
- Create an /etc/defaultdomain file with the domain name. You must maintain the format established by the original files and update the text files in the /etc directory (all of the files that are used for NIS maps) on the master server with information about the domain.
- If the files do not already exist, use the touch command to create zero-length files with the following names: /etc/ethers, /etc/bootparams, /etc/locale, /etc/timezone, /etc/netgroup, and /etc/netmasks. 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.
- Install an updated Makefile file in the /var/yp directory if you intend to use NIS on the system that functions as your JumpStartTM server. Performing this installation provides entries that create a map for the /etc/locale file, so that the locale information does not have to be provided by the sysidcfg file.
Note: The lab at the end of this module shows you how to create the updated Makefile file. - Create or populate the /etc/locale file, and make an entry for each domain on your network using the following format:
domainname locale
For example:
classroom.Central.Sun.COM en_US
- Initialize the master server by using the local /etc files. Enter the ypinit -m command.
# ypinit -m
- When the program prompts you for a list of slave servers and after you complete your list, press Control-D. You can make entries for all slaves now, or you can rerun the ypinit -m command after you determine whether you need more or less slave servers.
- The program asks if you want to terminate it on the first fatal error. If you answer n, the procedure reports any error and attempts to complete the creation of the NIS database files. If you answer y, the process aborts with the first error. You can correct the error and restart the ypinit program.
- Copy the /etc/nsswitch.nis file to the /etc/nsswitch.conf file. If necessary, modify the file.
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
next host to add: <Control-D>
The current list of yp servers looks like this:
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. - Start the NIS daemons on the master server with the following command:
# svcadm enable svc:/network/nis/server:default
- If you want to stop the NIS service running on the NIS master, perform the command:
# svcadm disable svc:/network/nis/server:default
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:
| Common
NIS Commands |
|
| Command | Description |
| ypcat | Prints values from an
NIS map |
ypmatch |
Prints the value of one or more keys from an
NIS map |
ypwhich |
Returns the name of the NIS server that supplies the NIS map services to an
NIS client |
Using the ypcat CommandThe following example prints the information from the hosts database.
$ ypcat hosts 192.168.30.30 instructor instructor1 127.0.0.1 localhost loghost 192.168.30.45 sys45 192.168.30.44 sys44 192.168.30.43 sys43 192.168.30.42 sys42 192.168.30.41 sys41 … <output truncated> …
Using the ypmatch Command
The following example matches individual host entries.
# ypmatch sys41 localhost hosts 192.168.30.41 sys41 127.0.0.1 localhost loghost
The following example matches a specific user in the password database.
# ypmatch user5 passwd user5:.dJJ.oofIqCLs:4005:10::/export/home/user5:/bin/ksh
Using the ypwhich Command
Perform the ypwhich command to identify the NIS server the client is bound to:
$ ypwhich sys44
When used with the -m option, the ypwhich command provides a list of all databases and the name of the master server for each map.
$ ypwhich -m … <output truncated> … timezone.byname sys44 netmasks.byaddr sys44 netid.byname sys44 bootparams sys44 netgroup.byhost sys44 netgroup.byuser sys44 netgroup sys44 … <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:
- Edit the /etc/inet/hosts file to ensure that the NIS master server and all slave servers have been defined.
- Execute the domainname domainname command to set the local NIS domain.
# domainname domainname
For example:
# domainname classroom.Central.Sun.COM
- Create or populate the /etc/defaultdomain file with the domain name.
- To initialize the system as an NIS client, perform the command:
# ypinit -c
- When the system prompts you for a list of NIS servers, enter the names of the NIS master and all slave servers.
- Copy the /etc/nsswitch.nis file to the /etc/nsswitch.conf file. If necessary, modify the file. 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.
- Start NIS with the following command:
# svcadm enable svc:/network/nis/client:default
- On the newly configured NIS client, test the NIS functionality by performing the command:
# ypwhich -m
The output shows a list of maps together with the NIS master server for each map.
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:
- Edit the /etc/inet/hosts file to ensure that the NIS master server and all slave servers have been defined.
- Execute the domainname domainname command to set the local NIS domain.
# domainname domainname
For example:
# domainname classroom.Central.Sun.COM
- Create or populate the /etc/defaultdomain file with the domain name.
- To initialize the system as an NIS client, perform the command:
# ypinit -c
- When the system prompts you for a list of NIS servers, enter the names of the NIS master and all slave servers.
- Copy the /etc/nsswitch.nis file to the /etc/nsswitch.conf file. If necessary, modify the file. 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.
- Start NIS with the following command:
# svcadm enable svc:/network/nis/client:default
- On the newly configured NIS client, test the NIS functionality by performing the command:
# ypwhich -m
The output shows a list of maps together with the NIS master server for each map.

