Network Information Service (NIS)

Network Information Services (NIS) enables you to create user accounts that can be shared across all systems on your network. The user account is created only on the NIS server. An advantage of NIS is that users need to change their passwords on the NIS server only, instead of every system on the network. This makes NIS popular in computer training labs, distributed software development projects or any other situation where groups of people have to share many different computers.

Install the NIS Server Packages

The following rpm are required to configure nis server. ypserv, cach, nfs, make, ypbind, portmap, xinetd check them if not found then install.
Why does everything related to NIS seem to start with the letters yp and not nis? The NIS system was originally called "Yellow Pages" but it was soon pointed out that British Telecom held a trademark on the term "Yellow Pages" so the name was changed to the Network Information Service. Part of the legacy of this name change is that most NIS commands and tools still begin with the letters yp.

Configure NIS server

The simplest NIS configuration consists of a single NIS server and one or more clients. In this case, NIS server configuration involves the following steps: The practical example I’m going to show that I have assigned server ip address and server name "mohitraj"
  1. Establish the domain name
  2. Create NIS user
  3. Edit /etc/yp.conf File
  4. Configure NFS server
  5. Editing the Makefile
  6. Using ypinit

Establishing the Domain for NIS Server

Edit Your /etc/sysconfig/network File.
/etc/sysconfig/network   NIS server

Significance of NISDOMAIN NIS domain shares a common set of maps. Each domain has a domain name. Each machine belongs to a domain; machines belonging to the same domain share the same maps.

Create NIS user

Before creating a new user we make a new directory. This directory is not a special configuration part of NIS. We make this directory for only NIS users. Make a new directory /nishome. (you can make own directory this directory work as a /home directory ) My NIS user is raj and I want to make its home directory in /nishome. Do as shown in figure.
NIS server user creation
NIS server user creation

Give the 777 permission to /nishome/raj directory
[root@mohitraj ~] chmod 777 /nishome/raj

Edit /etc/yp.conf File

NIS servers also have to be NIS clients themselves, so you'll have to edit the NIS client configuration file /etc/yp.conf to list the domain's NIS server as being the server itself or localhost.
NIS server /etc/yp.conf
NIS server /etc/yp.conf

Configure NFS server

Now open /etc/exports file
share /nishome/raj directory for network
Configure NFS for NIS
Configure NFS

Editing the Makefile

Changing over to the /var/yp directory, we see a file called Makefile (yes, all one word). file lists the files that get shared via NIS, as well as some additional parameters for how they get shared and how much of each one gets shared. Open up Makefile with your favourite editor, and you can see all the configurable options. The all Entry In the following makefile entry, all of the maps listed after all: are the maps that get shared.
NFS Server Editing the Makefile
NFS Server Editing the Makefile

Notice that the line continuation character, the backslash (\), is used to ensure that the make program knows to treat the entire entry as one line, even though it is really three lines. Based on this format, you can see that the maps configured to be shared are passwd, group, hosts, rpc, services, netid, protocols, and mail. For example, let’s say we want only the passwd, group,netid as shown in above figure above Note that the order in the all: line doesn’t matter.

Using ypinit

Once you have the makefile ready, you need to initialize the NIS server using the ypinit command.
NFS Server Using ypinit
NFS Server Using ypinit

Here, the -m option tells ypinit to set the system up as a master NIS server. Assuming we are running this on a system named mohitraj, we would see the system respond as follows:
NFS Server
NFS Server

Continue entering the name of all the secondary NIS servers. Press CTRL-D when you have added all necessary servers. As shown in figure below
NFS Server
NFS Server

These entries will be placed in the /var/yp/ypservers file for you; if needed, you can change them by editing the file later. Once you are done, ypinit will run the make program automatically for you, to build the maps and push them to any secondary servers you have indicated.
Time to start all the services
NFS Server service restart
NFS Server service restart

Configuring an NIS Client

Two rpm are required to configure clients yp-tools and ypbind check them for install. now open /etc/sysconfig/network set NISDOMAIN as we have done in server configuration.
Type command
[root@client ~]# setup A Window would be open as shown below. select authentication configuration from list
NFS Server Authentication
NFS Server Authentication

Now check mark on NIS and enter on next
NFS Server Authentication  selecting NIS
NFS Server Authentication selecting NIS

Set domain name toWISDOM and server to and click on ok
NFS Server setting Domain
NFS Server setting Domain

now open /etc/auto.master file write a line at the last
/nishome /etc/auto.misc
Save the file
now open /etc/auto.misc file
write like this
raj -rw,soft,intr
save the file
now restart autofs and ypbind service
[root@client ~]# service autofs restart
[root@client ~]# service ypbind restart
Open another console
Login as raj (nis user)
Use pwd command to know your current directory