Powered By Blogger

Monday, 11 April 2011

NIS Server Configuration in Centos

NIS Server Configuration

1st add users

[root@server ~]# adduser joao; passwd joao
[root@server ~]# adduser jose; passwd jose
[root@server ~]# adduser maria; passwd maria

2- Put an entry into /etc/exports like that below.

# vim /etc/exports

/home *(rw,sync)
/common *(rw,sync)

3- Run “exportfs -a” command.

[root@server ~]# exportfs -a

4- Make sure that nfs is enabled during boot time.

[root@server ~]# chkconfig nfs on

[root@server ~]# chkconfig –list nfs

5- Start nfs deamon.

[root@server ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]

Setting and installing NIS

1- Installing through yum. By default RHEL installs portmap, ypbind as well as yp-tools but
unfortunately it cannot be installed. To make sure type:

[root@server ~]# yum install portmap ypserv ypbind yp-tools

2- Open /etc/yp.conf and add new friendly lines: Where queirozpacheco.com is the domain and
server.queirozpacheco is the server.

Make sure if it hasn’t been defined in /etc/hosts yet.

[root@server ~]# vi /etc/yp.conf

domain nis.albiruni.comserver nis.albiruni.com

3- Type on shell these commands below.

[root@server ~]# domainname nis.albiruni.com
[root@server ~]# ypdomainname nis.albiruni.com

4- Start up ypserv service and put an entry in /etc/sysconfig/network file.

[root@server ~]# service ypserv start
Starting YP server services: [ OK ]

[root@server ~]# vim /etc/sysconfig/network
NISDOMAIN=nis.albiruni.com.com

5- Generate NIS init maps.

[root@server ~]# /usr/lib/yp/ypinit -m

Press Ctrl+d

next host to add:

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

server has been set up as a NIS master server.

Now you can run ypinit -s server on all slave server.
[root@server ~]#

6- Start up ypbind service.

[root@server ~]# service ypbind start
Binding to the NIS domain: [ OK ]
Listening for an NIS domain server.
[root@server ~]#

7- Start up yppasswdd service.

[root@server ~]# service yppasswdd start
Starting YP passwd service: [ OK ]
[root@server ~]#

8- Start up ypxfrd and portmap services.

[root@server ~]# service portmap start
Starting portmap: [ OK ]
[root@server ~]# service ypxfrd start
Starting YP map server: [ OK ]
[root@server ~]#

9- Make sure that these one will startup during the boot process.

[root@server ~]# for i in ypserv ypbind yppasswdd portmap ypxfrd; do chkconfig $i on; done
[root@server ~]#

10- were you thinking to check if ypserv is working correctly? Try this one.

[root@server ~]# rpcinfo -u localhost ypserv
program 100004 version 1 ready and waiting
program 100004 version 2 ready and waiting
[root@server ~]#

11- Finally, run make command in /var/yp directory.

[root@server ~]# cd /var/yp/
[root@server yp]# make
gmake[1]: Entering directory `/var/yp/nis.albiruni.com’
Updating netid.byname…
gmake[1]: Leaving directory `/var/yp/nis.albiruni.com’
[root@server yp]#

Client Setting on Server

Configuring AutoFS to mount /home directories.

1- Setting /etc/auto.master.

[root@host etc]# mv auto.master auto.master.backup

[root@host etc]# vi auto.master

/home /etc/auto.home –timeout 300

2- Create /etc/auto.home and make it out like this.

[root@host etc]# vi auto.home

* -fstype=nfs,soft,rsize=8192,wsize=8192,intr,tcp server:/home/&

3- Make sure if the nfs service works.

[root@host etc]# mount nis:/home /home
[root@host etc]# mount | grep nis
server:/home on /home type nfs (rw,addr=192.168.1.13)

Unmount at once.

[root@host etc]# umount /home

4- Install ypbind and portmap.

[root@host etc]# yum install ypbind portmap

5- Set through system-config-authentication tool as NIS client configuring:

Domain: nis.albiruni.com
Server: nis.albiruni.com

or Edit yp.conf in /etc like this. Edit also /etc/nsswitch.conf

domain nis.albiruni.com server nis.albiruni.com

and Edit nssswitch.conf and put these lines into that.

passwd: files nis

shadow: files nis

group: files nis

6- start up ypbind, autofs and portmap. Make sure that they will be startup during the boot.

[root@host ~]# service portmap start
[root@host ~]# service ypbind start
[root@host ~]# service autofs start

————————————-

[root@host ~]# for i in portmap autofs ypbind; do chkconfig $i on; done

7- You can try this to check if is working or not.

[root@host ~]# ypcat passwd
jose:$1$CSjl0r3p$BkSouhc2ENyZwsGAdO.58.:502:502::/home/jose:/bin/bash
joao:$1$kDne475.$1/XLOERyzye9uG4stE8Kc.:500:500::/home/joao:/bin/bash
maria:$1$xB8Livy9$jS7lpQubNdQxCIISEjln71:501:501::/home/maria:/bin/bash
[root@host ~]#

———————–

[root@host ~]# rpcinfo -u localhost ypbind
program 100007 version 1 ready and waiting
program 100007 version 2 ready and waiting
[root@host ~]#

Okay… Now, let’s get started to trying.

[root@server ~]# ssh jose@host
jose@host’s password:
Last login: Mon Feb 22 23:00:58 2010 from nis

1 comment: