NIS Configuration on CentOS/RHEL Linux

The Network Information Service or NIS (originally called Yellow Pages or YP) is a client–server directory service protocol for distributing system configuration data such as user and host names between computers on a computer network. Sun Microsystems developed the NIS; the technology is licensed to virtually all other Unix vendors.

On this tutorial we will see configuration of NIS for user management , NIS is a service that provides the same working environment to any user on that network irrespective of the system on that which has been used for login purpose. For example if NIS server is set up in a single system and configured to hold user accounts and their passwords and access information. Then any user on that network can login to his/her account that is set up in the NIS server from any system (with nis client running) on that configured network.

At first you need to define the NIS master server which contains all source files for the various maps like /etc/passwd, /etc/group or /etc/hosts. The NIS server process ypserv needs to be run on this host. The ypserv daemon is typically activated at system startup. There could be more hosts running ypserv, this one are called “slaves“. They get their maps from the master server. If a slave goes down, it will miss updates from the master.

On other machines using the NIS services as client, you have to run ypbind. ypbind must run on every machine which has NIS client processes; ypserv may or may not be running on the same node, but must be running somewhere on the network. For normal users, you need the yp-tools. This package provide tools for communication with ypbind, ypset and ypwhich, tools for accessing the NIS maps, ypcat, ypmatch and yppoll, and tools for changing NIS user information, ypchfn, ypchsh and yppasswd.

For Server:
Computer Name = webmanual01
IP Address = 10.190.195.156
NIS Domain Name= WEDDOMAIN

For Client:
Computer Name = webmanual02
IP Address = 10.190.195.160

Procesure to setup NIS for your environment

First Configure NFS Server to share /home folder of webmanual01

Task 1 :Install required package for nfs server:

[root@webmanual01 ~]# yum install nfs-utils
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Parsing package install arguments
Package 1:nfs-utils-1.0.9-40.el5.x86_64 already installed and latest version
Resolving Dependencies

OUTPUT Trancated …………………
…………………………………
…………………………………

Running Transaction
Installing : libgssapi [1/4]
Installing : nfs-utils-lib [2/4]
Installing : libevent [3/4]
Installing : nfs-utils [4/4]

Installed: nfs-utils.i386 1:1.0.9-40.el5
Dependency Installed: libevent.i386 0:1.1a-3.2.1 libgssapi.i386 0:0.10-2 nfs-utils-lib.i386 0:1.0.8-7.2.z2
Complete!

Task 2: Edit the /etc/exports file to allow NFS mounts of the /home directory with read/write access.

[root@webmanual01 ~]# vim /etc/exports
#Make the following entry and save the file Esc + wq!
/home *(rw,sync)

Task 3: Edit the /etc/sysconfig/nfs file to define static port numbers:

[root@webmanual01 ~]# vim /etc/sysconfig/nfs

#Make following entries in this file and save the file ESC + wq!#
MOUNTD_PORT=”4002″
STATD_PORT=”4003″
LOCKD_TCPPORT=”4004″
LOCKD_UDPPORT=”4004″

Task 4 : Restart following services:

/etc/init.d/nfs start
/etc/init.d/portmap restart
/etc/init.d/nfslock restart

[root@webmanual01 ~]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@webmanual01 ~]# /etc/init.d/portmap restart
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
[root@webmanual01 ~]# /etc/init.d/nfslock restart
Stopping NFS locking: [ OK ]
Stopping NFS statd: [ OK ]
Starting NFS statd: [ OK ]
[root@webmanual01 ~]#

Task 5 : Set following services to automatically start at boot time:

chkconfig nfs on
chkconfig portmap on
chkconfig nfslock on

Task 6 : Show the exported files :

[root@webmanual01 ~]# exportfs -avf
exporting *:/home
[root@webmanual01 ~]#

Configure NIS Server Now:

Task 1 : Install packages required (ypserv, ypbind, yp-tools) for NIS Server.

[root@webmanual01 ~]# yum install ypserv ypbind yp-tools
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Parsing package install arguments

OUTPUT Trancated ……………………
…………………………………..

Running Transaction
Installing : ypserv [1/4]
Installing : ypserv [2/4]
Installing : yp-tools [3/4]
Installing : ypbind [4/4]

Installed: yp-tools.i386 0:2.9-0.1 ypbind.i386 3:1.19-11.el5 ypserv.x86_64 0:2.19-5.el5 ypserv.i386 0:2.19-5.el5
Complete!
[root@webmanual01 ~]#

Task 2 : Edit /etc/sysconfig/network to add following entry:

HOSTNAME=webmanual01
NISDOMAIN=”WEBDOMAIN”

Here the WEMDOMAIN is the NIS domain name.

Task 3 : Start following NIS services:

service ypserv start
service yppasswdd start
service portmap restart

Example

[root@webmanual01 ~]# service ypserv start
Setting NIS domain name WEBDOMAIN: [ OK ]
Starting YP server services: [ OK ]
[root@webmanual01 ~]# service yppasswdd start
Starting YP passwd service: [ OK ]
[root@webmanual01 ~]# service portmap restart
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
[root@webmanual01 ~]#

Task 4 : Set following services to automatically start at boot time:

chkconfig ypserv on
chkconfig yppasswdd on
chkconfig ypxfrd on

Task 5: Now add NIS client to NIS server by running comand /usr/lib/yp/ypinit -m

[root@webmanual01 ~]# /usr/lib/yp/ypinit -mAt this point, we have to construct a list of the hosts which will run NIS
servers. webmanual01 is in the list of NIS server hosts. Please continue to add
the names for the other hosts, one per line. When you are done with the
list, type a .
next host to add: webmanual01
next host to add: webmanual02 ———> NIS client webmanual02 Server Added
next host to add:
The current list of NIS servers looks like this:webmanual01
webmanual02Is this correct? [y/n: y] y ——–> Press Y once you complete adding
We need a few minutes to build the databases…
Building /var/yp/WEBDOMAIN/ypservers…
gethostbyname(): Success
Running /var/yp/Makefile…
gmake[1]: Entering directory `/var/yp/WEBDOMAIN’
Updating passwd.byname…
Updating passwd.byuid…
Updating group.byname…
Updating group.bygid…
Updating hosts.byname…
Updating hosts.byaddr…
Updating rpc.byname…
Updating rpc.bynumber…
Updating services.byname…
Updating services.byservicename…
Updating netid.byname…
Updating protocols.bynumber…
Updating protocols.byname…
Updating mail.aliases…
gmake[1]: Leaving directory `/var/yp/WEBDOMAIN’webmanual01 has been set up as a NIS master server.Now you can run ypinit -s webmanual01 on all slave server.
[root@webmanual01 ~]#

Task 6 : Add user

[root@webmanual01 ~]# useradd abinash
[root@webmanual01 ~]# passwd abinash
Changing password for user abinash.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@webmanual01 ~]#

Task 7 : Update the NIS domain’s authentication files by executing the “make” command in the /var/yp directory as below

[root@webmanual01 ~]# cd /var/yp

[root@webmanual01 yp]# ls -l
total 40
drwxr-xr-x 2 root root 4096 Dec 9 2008 binding
-rw-r–r– 1 root root 16669 Aug 11 2008 Makefile
-rw-r–r– 1 root root 185 Jul 13 2006 nicknames
drwxr-xr-x 2 root root 4096 Apr 19 04:49 WEBDOMAIN
-rw-r–r– 1 root root 24 Apr 19 04:48 ypservers

[root@webmanual01 yp]# make
gmake[1]: Entering directory `/var/yp/WEBDOMAIN’
Updating passwd.byname…
Updating passwd.byuid…
Updating group.byname…
Updating group.bygid…
Updating hosts.byname…
Updating hosts.byaddr…
Updating netid.byname…
gmake[1]: Leaving directory `/var/yp/WEBDOMAIN’
[root@webmanual01 yp]#

On Client Side configure auto.home and auto.master on server webmanual02

Task 1 : Make following entry in /etc/auto.home
* -fstype=nfs,soft,intr serveripaddress:/home/&

Example

[root@webmanual02 ~]# cat /etc/auto.home

* -fstype=nfs,soft,intr 10.190.195.156:/home/&

Task 2 : Make following entry in /etc/auto.master

/home /etc/auto.home

Task 3 : Start autofs service and set it to automatically start at boot time.

[root@webmanual02 ~]# service autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
[root@webmanual02 ~]# chkconfig autofs on
[root@webmanual02 ~]#

Task 4 : Now run authconfig-tui — > Use NIS–> Fill up the following information

Domain: NISDOMAIN
Server: 10.190.195.156

Then Press OK and you will get output like below

[root@webmanual02 ~]# authconfig-tui
Stopping portmap: [ OK ]
Starting portmap: [ OK ]
Binding to the NIS domain: [ OK ]
Listening for an NIS domain server…

Now login with user abinash to client machine .

Conclusion

NIS is a very useful tool for centralized login management, but it has two shortcomings: NIS clients are typically limited to Unix or Linux operating systems, and the password information passes over the network unencrypted.

Tags: , ,