May 23, 2018

Install NIS Server for Linux

Install and configure NIS master only

First install the packages that needed by NIS:

yum install yp-tools ypbind ypserv

Add NIS domain name to /etc/sysconfig/network

echo ‘NISDOMAIN=domain.com’ >> /etc/sysconfig/network

Add the NIS server ip address to /etc/yp.conf

echo ‘ypserver 127.0.0.1’ >> /etc/yp.conf

Edit yp to make file:

sed -i ‘s/MERGE_PASSWD=true/MERGE_PASSWD=false/g’ /var/yp/Makefile
sed -i ‘s/MERGE_GROUP=true/MERGE_GROUP=false/g’ /var/yp/Makefile
sed -i ‘s/all:/all: shadow/g’ /var/yp/Makefile

Add your NIS server IP address /etc/hosts:

vi /etc/hosts

192.168.50.10 nis-srv1 nis-srv1.domain.com

Check all YP’s services are started:

chkconfig ypbind on
chkconfig yppasswdd on
chkconfig rpcbind on
chkconfig ypxfrd on
chkconfig ypserv on

You can start only this services:

service yppasswdd start
service rpcbind start
service ypxfrd start
service ypserv start

Create and Update NIS database:

/usr/lib64/yp/ypinit -m
Ctrl+D
y

Start the ypbind NIS client service:

service ypbind start

or

/etc/init.d/ypbind start

Now you need to compile the NIS database:

cd /var/yp

make

Install and configure NIS Master/Slave

Install NIS components on the NIS slave server:

yum install yp* -y

Check that all  services are started at boot:

chkconfig ypbind on
chkconfig ypxfrd on
chkconfig yppasswdd on
chkconfig ypserv on

The host file must be updated:

vi /etc/hosts

192.168.50.10 nis-srv1 nis-srv1.domain.com
192.168.50.11 nis-srv2 nis-srv2.domain.com

Add NIS domain name to /etc/sysconfig/network

echo ‘NISDOMAIN=domain.com’ >> /etc/sysconfig/network

Add the NIS master server ip address to /etc/yp.conf

echo ‘ypserver ‘ >> /etc/yp.conf

Direct the NIS slave server to transfer the data from the NIS master:

/usr/lib64/yp/ypinit -s 192.168.50.10   # NIS master IP address

Directs the system to use NIS for user authentication:

sed -i ‘s/shadow: files/shadow: files nis/’ /etc/nsswitch.conf
sed -i ‘s/passwd: files/passwd: files nis/’ /etc/nsswitch.conf
sed -i ‘s/hosts: files dns/hosts: files dns nis/’ /etc/nsswitch.conf
sed -i ‘s/group: files/group: files nis/’ /etc/nsswitch.conf

Use the NIS localhost server:

sed -i ‘s/ypserver.*/ypserver 127.0.0.1/’ /etc/yp.conf

Start NIS services:

service ypserv start
service yppasswdd start

PUSH function is needed by the master server to update the slave server:

sed -i ‘s/NOPUSH=true/NOPUSH=false/g’ /var/yp/Makefile

NIS master has file call ypservers locate /var/yp/ypservers, add NIS slave server to this file:

vi /var/yp/ypservers

nis-srv1   # Master

nis-srv2    # Slave

Update the NIS database by Make command:

cd /var/yp

make

Optional: configure cron job replication between NIS master to NIS slave:

vi /etc/cron.d/nis-replication
* 01 * * * /usr/lib64/yp/ypxfr # replication every hour

Restart the Corn service:

service crond restart

Or

/etc/init.d/crond restart

Restart NIS services on the NIS slave server:

service ypbind restart
service yppasswd restart
service ypserv restart
service ypxfrd restart

Or

/etc/init.d/ypbind restart
/etc/init.d/yppasswd restart
/etc/init.d/ypserv restart
/etc/init.d/ypxfrd restart

Install the Client NIS node.

After you’re Done to install and configuring NIS master/slave, now it’s time to install the Client NIS node.

First, install all needed packages:

yum install ypbind yp-tools -y

Automatic configuration:

after installing all NIS client packages run this command to automatic configuration:

authconfig –update –nisdomain=domain.com –nisserver=nis-srv1 –enablenis –enablemkhomedir

Configuring the service to start at boot:

chkconfig ypbind on
service ypbind start.

Manual configuration

Add NIS domain to /etc/sysconfig/network:

echo ‘NISDOMAIN=domain.com’ >> /etc/sysconfig/network

Edit the /etc/yp.conf file and add NIS server:

echo ‘domain domain.com server nis-srv1’ >> /etc/yp.conf

Edit the /etc/hosts file and add NIS server:

echo ‘192.168.50.10 nis-srv1 nis-srv1.domain.com’ >> /etc/hosts

Edit the nisswitch.conf file to access NIS DB:

sed -i ‘s/shadow: files/shadow: files nis/’ /etc/nsswitch.conf
sed -i ‘s/passwd: files/passwd: files nis/’ /etc/nsswitch.conf
sed -i ‘s/hosts: files dns/hosts: files dns nis/’ /etc/nsswitch.conf
sed -i ‘s/group: files/group: files nis/’ /etc/nsswitch.conf

Run this command to create missing home directory:

echo ‘session optional pam_mkhomedir.so skel=/etc/skel umask=077’ >> /etc/pam.d/system-auth

Configuring the service to start at boot:

chkconfig ypbind on
service ypbind start.

Troubleshooting

Adding new user.

login to NIS Master and create new user and password:

useradd nisuser

passwd nisuser

After you create the user, you need to update the NIS database:

cd /var/yp

make

ypbind not started:

binding NIS service : [FAILED]

fixed: just stop NetworkManager

#  service NetworkManger stop

ypbind is crashing:

ypbind daemon crashing when you have unstable connection, to fix it, edit to the /etc/init.d/ypbind and add this command.

sed -i ‘s/OTHER_YPBIND_OPTS=””/OTHER_YPBIND_OPTS=”-no-ping”/g’ /etc/init.d/ypbind

when you try to login to user you received

-sh-4.1$ instead of the user Linux profile

You have 3 options:

  1. Change the defaults login shell from /bin/sh to /bin/bash
  2. restart ypserv /etc/init.d/ypserv restart
  3. restart ypbind /etc/init.d/ypbind restart

About The Author

IT professional for 17 years in complex networking Linux and Windows environments.

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Fatal error: Call to undefined function pp_popup() in /home/shira13/public_html/wp-content/themes/multinews/footer.php on line 73