The NIS (Network Information Service) is used to share information that needs to be used on all hosts on the network. NIS origin is Sun Microsystems Yellow Page, but YP has registered the company, so took the name NIS, NIS server Management account information, if all clients are in the domain, then only need one NIS server storage users can be, No need to store every machine
Software Installation
[[email protected] ~]# yum install ypserver[[email protected] ~]# Rpm-qa | grep Ypypbind-1.19-12.el5_6.1ypserv-2.19-10.el5_9.1yp-tools-2.9-2.el5
Set the domain name
[[email protected] ~]# nisdomainname nis[[email protected] ~]# vi/etc/sysconfig/network 1 networking=yes 2 Networking_ipv6=yes 3 hostname=alicia.net 4 Nisdomain=nis
Configure and start the daemon
[[email protected] ~]# vi/etc/rc.d/rc.local 1 #!/bin/sh 2 # 3 # This script would be executed *after* all the Other init scripts. 4 # can put your own initialization stuff in here if you don ' t 5 # Want to do the full Sys V style init stuff.
6 7 touch/var/lock/subsys/local 8 Nisdomainname NIS
Configure access rights
[[email protected] ~]# vi/etc/ypserv.conf 127.0.0.1/255.255.255.0 : * : *: None 51 10.8.118.0/ 255.255.255.0: *: *: None *: *: *: deny
Adding Test users
[Email protected] ~]# useradd nis[[email protected] ~]# passwd nischanging password for user Nis. New UNIX Password:bad Password:it is based on a dictionary wordretype new UNIX password:passwd:all authentication Toke NS updated successfully.
Initializing NIS mappings
[[email protected] ~]# service ypserv restartstopping YP Server services: [Failed]start ing YP Server services: [OK][[email protected] ~]#/usr/lib/yp/ypinit-m at the This PO int, we have to construct a list of the hosts which would run Nisservers. CentOS is in the list of NIS server hosts. Continue to Addthe names for the other hosts, one per line. When you were done with thelist, type a <control d>. Next host to Add:centos next host to Add:alicia.net next host to Add:alicia next host to add: The current list of NIS servers looks like this:centosalicia.netaliciaIs this correct? [y/n: y] ywe need a few minutes to build the databases ... Building/var/yp/nis/ypservers ... RUNNING/VAR/YP/MAKEFILE...GMAKE[1]: Entering directory '/var/yp/nis ' 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 ' CentOS have been set up as a NIS master server. Now the can run Ypinit-s CentOS on all slave server.
Start the service
[[Email protected] ~]# service Ypserv restartstopping YP Server services: [ OK ]starting YP Server services:< c3/>[ OK ][[email protected] ~]# service YPPASSWDD restartstopping YP passwd service: [failed]starting YP passwd service: [ OK ]
Client
Software Installation
[Email protected] ~]# Rpm-qa | grep ypyp-tools-2.9-2.el5ypbind-1.19-12.el5_6.1
NIS settings
[Email protected] ~]# nisdomainname nis[[email protected] ~]# vi/etc/sysconfig/networknetworking=yesnetworking_ipv6= Yeshostname=samsunnisdomain=nis[[email protected] ~]# vi/etc/rc.d/rc.local #!/bin/sh## This script would be executed *aft er* all the other init scripts.# you can put your own initialization stuff in here if you don ' t# want to do the full Sys V Style init Stuff.touch/var/lock/subsys/localdomainname nis~
Set up hosts to find NIS server
[[email protected] ~]# vi/etc/hosts# do not remove the following line, or various programs# that require network function Ality'll fail.127.0.0.1 centos localhost.localdomain localhost Samsun samsun.net::1 Localhost6.localdomain6 localhost610.8.118.100 alicia.net
Modify Client Configuration
[Email protected] ~]# vi/etc/yp.conf ypserver alicia.net
Modify the Certification file
[Email protected] ~]# vi/etc/nsswitch.conf # example:29 #passwd: db Files Nisplus NIS #shadow: db fil Es nisplus NIS #group: db Files Nisplus NIS passwd: files NIS shadow: files NIS Group: Files NIS
Client service startup
[Email protected] ~]# service Ypbind restartshutting down NIS services: [failed]binding to the NIS domain: [ OK ]listening for the NIS domain server.
At this point, the client can use the Nis/password user to log in, because it has been added to the domain NIS, NIS server has this user, it can also be used
Linux NIS Server