Sunday, 23 September 2012

How to Configure NIS in rhel 6 / centos 6.3


-->
[root@station1 ~]# vim /etc/exports
/nis *(rw,sync)
[root@station1 ~]# chkconfig nfslock on
[root@station1 ~]# chkconfig rpcbind on
[root@station1 ~]# chkconfig nfs on
[root@station1 ~]# service nfslock restart
[root@station1 ~]# service rpcbind restart
[root@station1 ~]# service nfs restart
[root@station1 Desktop]# showmount -e
Export list for station1.ranjihat.com:
/nis *
[root@station1 ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=station1.ranjihat.com
NISDOMAIN=ranjihat.com
[root@station1 ~]# vim /etc/hosts
127.0.0.1 station1 station1.ranjihat.com
10.65.62.35 station2 station2.ranjihat.com
[root@station1 ~]# vim /etc/yp.conf
ypserver 127.0.0.1
[root@station1 ~]# service rpcbind restart
[root@station1 ~]# yum install ypserv
[root@station1 ~]# service ypserv start
Setting NIS domain name ranjihat.com: [ OK ]
Starting YP server services: [ OK ]
[root@station1 ~]# chkconfig ypserv on
[root@station1 ~]# service ypxfrd start
Starting YP map server: [ OK ]
[root@station1 ~]# chkconfig ypxfrd on
[root@station1 ~]# /usr/lib64/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS
servers. station1 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 <control D>.
next host to add: station1
next host to add: station2
next host to add:
The current list of NIS servers looks like this:

station1
station2

Is this correct? [y/n: y] y
We need a few minutes to build the databases...
Building /var/yp/ranjihat.com/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/ranjihat.com'
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/ranjihat.com'

station1 has been set up as a NIS master server.

Now you can run ypinit -s station1 on all slave server.


 
[root@station1 ~]# useradd -g users nisuser
[root@station1 ~]# passwd nisuser
[root@station1 ~]# cd /var/yp/
[root@station1 yp]# make
gmake[1]: Entering directory `/var/yp/ranjihat.com'
Updating passwd.byname...
Updating passwd.byuid...
Updating netid.byname...
gmake[1]: Leaving directory `/var/yp/ranjihat.com'
[root@station1 yp]# service ypxfrd restart
Stopping YP map server: [ OK ]
Starting YP map server: [ OK ]
[root@station1 yp]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
[root@station1 yp]# service ypserv restart
Stopping YP server services: [ OK ]
Starting YP server services: [ OK ]
[root@station1 yp]# service ypbind restart
Shutting down NIS service: [ OK ]
Starting NIS service: [ OK ]
Binding NIS service: . [ OK ]

“You can check to see if the user's authentication information has been updated by using the ypmatch command, which should return the user's encrypted password string.”

[root@station1 yp]# ypmatch nisuser passwd
nisuser:$6$fNtdmOBc$/0uLt/p7WYkXKtJF5EsiV0Qq9tNfN3PukJAVncuyDIGgmR2G6PYNGxoqPM8GpFOp6r3GQdwBr6a1xdLk.gzBW/:501:100::/nis/nisuser:/bin/bash

[root@station1 yp]# getent passwd nisuser
nisuser:x:501:100::/nis/nisuser:/bin/bash

CLIENT SIDE i.e at station2.ranjihat.com

[root@station2 Desktop]# authconfig-tui 

Starting rpcbind: [ OK ]
Shutting down NIS service: [ OK ]
Starting NIS service: [ OK ]
Binding NIS service: . [ OK ]
[root@station2 Desktop]# vim /etc/auto.master
/nis /etc/auto.misc
[root@station2 Desktop]# vim /etc/auto.misc
nisuser -rw 10.65.62.30:/nis/nisuser
[root@station2 Desktop]# service ypbind restart
Shutting down NIS service: [ OK ]
Starting NIS service: [ OK ]
Binding NIS service: . [ OK ]

[root@station2 Desktop]# service autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
[root@station2 Desktop]# su - nisuser
[nisuser@station2 ~]$ pwd
/nis/nisuser
[nisuser@station2 ~]$ exit
logout

Thats it you have successfully completed your nis configuration.

NOTE: You wont find nisuser in your client pc because you r just loggin a nisuser remotely from nis server.

[root@station2 Desktop]# cat /etc/passwd |grep nisuser
[root@station2 Desktop]#

Any queries contact me..

15 comments:

  1. nice post, but I'd like that you explain step for step what did you do? but It's okay!
    Thanks for the tutorial dude!

    ReplyDelete
  2. i followed the same step but i got the error " could not update ICEauthority file /home/user/ICEauthority
    /usr/libexec/gconf-sanity-check-2 exited with status 256

    ReplyDelete
  3. How to solve this error? any permission issue here with /nis?

    ReplyDelete
  4. but we can't see nis user in login page give some step to to login with nis users from login page..

    ReplyDelete
    Replies
    1. For the above steps itself am getting the user name in login screen of client pc's. Try keeping chkconfig autofs on in your client pc.

      Delete
  5. i get a error cannot change directory to /home/nisuser: no such file and directory

    ReplyDelete
    Replies
    1. after authconfig-tui step, whether u r getting output for "getent passwd nisuser". if u get it then confi autofs properly as shown in my steps above. check whether iptables and selinux are disabled in your nis server.

      Delete
  6. hi ranjith,
    i completed master server & client server configuration...
    but i am getting problem while configuring slave server...
    those problems are...
    1. i started ypxfrd service in slave(service ypxfrd start); after starting i checked the status(service ypxfrd status) but is showing "rpc.ypxfrd stopped"

    2. [root@nisslave tmp]# /usr/lib/yp/ypinit -s bigboy
    Can't enumerate maps from bigboy. Please check that it is running. this is error coming when trying to run the above command

    3. i am getting users list from master and slave; but whenever i turn off mastrer server client not able to communicate with slave server...

    plz help me... because i am doing project on nis only :(

    ReplyDelete
    Replies
    1. check whether your slave server resolves properly with your master. using nslookup, if not make a entry in /etc/host or in your dns zone files. if your /usr/lib/yp/ypinit -s bigboy executes successfully then only your master databases will synch with slave so that when your master is down you can able to login from slave and make your client pc to search for slave server, not for master server. Before starting ypxfrd in slave, start the same service once in master too. try once and revert back.

      Delete
  7. hello ranjith.i am so new to linux.i had installed cent os 6.3 and tried to configured nis as you supposed..but when i type the command

    #/usr/lib64/yp/ypinit -m command it shows

    station1
    station2

    Is this correct? [y/n: y] y
    We need a few minutes to build the databases...
    Building /var/yp/server.com/ypservers...
    Running /var/yp/Makefile...
    gmake[1]: Entering directory `/var/yp/server.com'
    Updating passwd.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating passwd.byuid...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating group.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating group.bygid...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating hosts.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating hosts.byaddr...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating rpc.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating rpc.bynumber...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating services.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating services.byservicename...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating netid.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating protocols.bynumber...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating protocols.byname...
    failed to send 'clear' to local ypserv: RPC: Unknown hostUpdating mail.aliases...
    failed to send 'clear' to local ypserv: RPC: Unknown hostgmake[1]: Leaving directory `/var/yp/server.com'

    ReplyDelete
    Replies
    1. Check the "rpcbind (portmap)" Service is running before make.

      Delete
  8. Is there any way to Sync users,Group, Passwd from Active directory to NIS server?

    Regards,
    Swapnil

    ReplyDelete
  9. is rpcbind and portreserve or portmap are the same services....

    ReplyDelete
  10. Nice Post... i'm system admin.. i configured NIS server and we hve 20 workstations ,all are logging with nis users...so tell me how to check on server side howmany nis client users connected in my NIS server?

    ReplyDelete