NIS required only when NIS (Network Information Service) is used, Nis involve only with the user registration etc. only to the server. The article below the step by step setup and configure the NIS server and NIS client on Fedora operating system, the article also include the setup of portmap, nsswitch and using tools such as ypwhich, ypcat and ypmatch.
Setting of NIS domain server and client
The following line is added to /etc/sysconfig/network.
NISDOMAIN=nisdomain.com
Portmapper should start to operate NIS and NFS.
Portmapper allocates the TCP/UDP port number in the RPC service program.
The main RPC service program PORTMAPPER,NFS,YPSERV,MOUNTD,YPBIND,YPPASSWDD
Portmap installation
[root@tenouk ~]# mount /dev/cdrom
[root@tenouk ~]# cd /mnt/cdrom/RedHat/RPMS
[root@tenouk ~]# rpm –Uhv portmap-4.0-38.i386.rpm
[root@tenouk ~]# cd /
[root@tenouk ~]# umount /dev/cdrom
Start and stop portmap service
[root@tenouk ~]# /sbin/service portmap start
[root@tenouk ~]# /sbin/service portmap stop
Confirmation of automatic start of portmap
List the automatic start for portmap service.
[root@tenouk ~]# /sbin/chkconfig --list portmap
Setting of automatic start of portmap.
[root@tenouk ~]# /sbin/chkconfig --level 35 portmap on
Setting of NIS Server
NIS installation
[root@tenouk ~]# mount /dev/cdrom
[root@tenouk ~]# cd /mnt/cdrom/RedHat/RPMS
[root@tenouk ~]# rpm –Uhv ypserv-1.3.12-2.i386.rpm
[root@tenouk ~]# cd /
[root@tenouk ~]# umount /dev/cdrom
Control of ypserv
[root@tenouk ~]# /sbin/service ypserv start
[root@tenouk ~]# /sbin/service ypserv stopt
Setting of automatic start of ypserv
[root@tenouk ~]# /sbin/chkconfig --level 35 ypserv on
Confirmation of automatic start of ypserv
[root@tenouk ~]# /sbin/chkconfig --list ypserv
Ypserv controls the access by /var/yp/securenets.
[root@tenouk ~]# vi /var/yp/securenets
0.0.0.0 0.0.0.0 //The access from all hosts is permitted.
255.255.255.0 192.168.0.0
Ypserv responds only from the host who belongs to 192.168.0.0/24.
NIS Map
One NIS server or more is necessary to use NIS. NIS data bases contains user information and host information, etc. are put on the NIS server. One of NIS must becomes a master server when two or more NIS servers are prepared, and the remain becomes a slave server. All information is set on the master server, and the slave server maintains the copy. The file such as /etc/passwd on the master server is converted into the NIS map.
Example of NIS map
(file) (nis map)
passwd passwd.byname passwd.byuid
hosts hosts.byname hosts.byaddr
Making NIS map
1. Information necessary for the file is written If it is for instance /etc/hosts, the host name and Internet Protocol address are written.
2. The NIS data base is made from these files.
[root@tenouk ~]# cd /var/yp
[root@tenouk ~]# make
Setting of master server
Information in the NIS map is reflected in the mastering server.
[root@tenouk ~]# /usr/lib/yp/ypinit –m
The NIS slave server name is heard when executing.
Besides, when the NIS server does not exist, ends if CTRL+D is input.
Setting of slave server
[root@tenouk ~]# /usr/lib/yp/ypinit –s masterservername
Information in the NIS map is automatically copied from the master server.
Setting of NIS client
The installation process of ypbind and yp-tools.
[root@tenouk ~]# mount /dev/cdrom
[root@tenouk ~]# cd /mnt/cdrom/RedHat/RPMS
[root@tenouk ~]# rpm –Uhv ypbind-1.8-1.i386.rpm
[root@tenouk ~]# rpm –Uhv yp-tools-2.5-1.i386.rpm
[root@tenouk ~]# cd /
[root@tenouk ~]# umount /dev/cdrom
Beginning and stop of ypbind)
[root@tenouk ~]# /sbin/service ypbind start
[root@tenouk ~]# /sbin/service ypbind stop
Setting of automatic start)
[root@tenouk ~]# /sbin/chkconfig --level 35 ypbind on
Confirmation of automatic start
[root@tenouk ~]# /sbin/chkconfig --list ypbind
Specification of nis server
Open and edirt yp.conf file.
[root@tenouk ~]# vi /etc/yp.conf
# /etc/yp.conf - ypbind configuration file
# Valid entries are
#
#domain NISDOMAIN server HOSTNAME
# Use server HOSTNAME for the domain NISDOMAIN.
#
#domain NISDOMAIN broadcast
# Use broadcast on the local net for domain NISDOMAIN
#
#ypserver HOSTNAME
# Use server HOSTNAME for the local domain. The
# IP-address of server must be listed in /etc/hosts.
#
Setting of name service switch
For instance, information on the user has two of information from /etc/passwd and NIS of each client. Moreover, the host name has three of information from /etc/hosts, NIS, and DNS of each client. By what priority level these information is used specifies the name service switch depending.
[root@tenouk ~]# vi /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# nisplus or nis+ Use NIS+ (NIS version 3)
# nis or yp Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
# db Use the local database (.db) files
# compat Use NIS on compat mode
# hesiod Use Hesiod for user lookups
# [NOTFOUND=return] Stop searching if not found so far
#
# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files nisplus
shadow: files nisplus
group: files nisplus
#hosts: db files nisplus nis dns
hosts: files nisplus dns
# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files nisplus
rpc: files
services: files nisplus
netgroup: files nisplus
publickey: nisplus
automount: files nisplus
aliases: files nisplus
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# nisplus or nis+ Use NIS+ (NIS version 3)
# nis or yp Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
# db Use the local database (.db) files
# compat Use NIS on compat mode
# hesiod Use Hesiod for user lookups
# [NOTFOUND=return] Stop searching if not found so far
#
# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files nisplus
shadow: files nisplus
group: files nisplus
#hosts: db files nisplus nis dns
hosts: files nisplus dns
# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files nisplus
rpc: files
services: files nisplus
netgroup: files nisplus
publickey: nisplus
automount: files nisplus
aliases: files nisplus
Using ypwhich
Ypwhich displays which NIS server to be used.
[root@tenouk ~]# ypwhich
nisdomainA
[root@tenouk ~]#
The list of the data base map is output
[root@tenouk ~]# ypwhich –x
Use "ethers" for map "ethers.byname"
Use "aliases" for map "mail.aliases"
Use "services" for map "services.byname"
Use "protocols" for map "protocols.bynumber"
Use "hosts" for map "hosts.byname"
Use "networks" for map "networks.byaddr"
Use "group" for map "group.byname"
Use "passwd" for map "passwd.byname"
$
Using ypcat
Display the content of the NIS data base output.
Nis passwd
[root@tenouk ~]# ypcat passwd
nfsnobody:!!:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
kimura:$1$e9/Rybex$xgn0t2ioIJuCjzLOiFIua1:500:500::/home/kimura:/bin/bash
[root@tenouk ~]#
hosts file
[root@tenouk ~]# ypcat hosts
10.10.0.234 nt
127.0.0.1 RedHatA localhost.localdomain localhost
127.0.0.1 RedHatA localhost.localdomain localhost
10.10.0.235 RedHatA
[root@tenouk ~]#
Using ypmatch
A specific key word of the NIS data base is retrieved, and the result is output.
[root@tenouk ~]# ypmatch nt hosts
10.10.0.234 nt
[root@tenouk ~]#