一、Server端:
[root@server~]yum install yp*
[root@server~]yum install portmap
[root@server~]nisdomainname linux
[root@server~]vim /etc/sysconfig/network
NISDOMAIN=linux
[root@server~]vim /etc/rc.d/rc.local
/bin/nisdomainname linux
[root@server~]vim /etc/ypserv.conf
127.0.0.0/255.255.255.0 : * : * : none
192.168.0.0/255.255.255.0 : * : * : none
* : * : * : deny
[root@server~]/usr/lib/yp/ypinit –m
[root@server~]service ypserv restart
[root@server~]service yppasswdd restart
[root@server~]vim /etc/exports
/nishome/nisuser1 *(rw)
[root@server~]mkdir /nishome
[root@server~]chmod 777 /nishome
[root@server~]useradd –d /nidhome/nisuser1 nisuser1
[root@server~]passwd nisuser1
[root@server~]service nfs restart
注意:固定端口
[root@server~]vim /etc/sysconfig/network
YPSERV_ARGS=”-p 1019”
YPXFRD_ARGS=”-p 1016”
防火牆設置:(111:portmap)
[root@server~]vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT –p tcp –dport 1019 –j ACCEPT
-A RH-Firewall-1-INPUT –p udp –dport 1019 –j ACCEPT
-A RH-Firewall-1-INPUT –p tcp –dport 111 –j ACCEPT
-A RH-Firewall-1-INPUT –p udp –dport 111 –j ACCEPT
二、client端:
[root@client~]yum install yp*
[root@client~]nisdomainname linux
[root@client~]vim /etc/sysconfig/network
NISDOMAIN=linux
[root@client~]vim /etc/rc.d/rc.local
/bin/nisdomainname linux
[root@client~]vim /etc/hosts
192.168.0.4 nis
[root@client~]vim /etc/nsswitch.conf
Passwd: file nis
Shadow: file nis
Group: file nis
Hosts: file nis dns
[root@client~]vim /etc/yp.conf
Domain linux
Ypserver nis
注:清空其他文字
[root@client~]vim /etc/auto.master
/nishome /etc/auto.home
[root@client~]vim /etc/auto.home
* -fstype=nfs 192.168.0.4:/nishome/&
[root@client~]service autofs restart
[root@client~]service ypbind restart