NIS即网络信息系统(Network Information Service),是对主机账号等系统信息提供集中管理的网络服务,本文将详细描述服务端和客户端的设置。
NIS Server (RHEL5.3)
-------------------------------------------------
1.设置服务器IP地址
# ifconfig eth0 192.168.1.1/24
2.挂载光盘
# mount /dev/cdrom /media
3.安装ypserv软件包
# cd /media/Server
# rpm -ivh ypserv-2*
4.设置time和time-udp服务的启动状态
# chkconfig time-dgram on
# chkconfig time-stream on
# chkconfig --list |grep time
# service xinetd restart
5.建立NIS的域名
# nisdomainname linux
# echo /bin/nisdomainname linux >> /etc/rc.d/rc.local
同时还要将NISDOMAIN=linux配置添加到/etc/sysconfig/network文件中
# echo NISDOMAIN=linux >> /etc/sysconfig/network
6.设置ypserv服务的配置文件
# vi /etc/ypserv.conf
127.0.0.0/255.255.255.0  : * : * : none
192.168.1.0/255.255.255.0 : * : * : none
*    : * : * : deny
:wq
7.添加securenets安全配置文件
# vi /var/yp/securenets
host 127.0.0.1
255.255.255.0 192.168.1.0
:wq
8.启动NIS服务器
启动之前需检查portmap服务是否启动
# service portmap status
# service ypserv start
# service yppasswdd start
9.启动ypserv和yppasswdd服务程序的35运行级别
# chkconfig --level 35 ypserv on
# chkconfig --level 35 yppasswdd on
10.构建NIS数据库
# /usr/lib/yp/ypinit -m
然后按Ctrl + d组合键
# ls /var/yp/linux
11.重启这两个服务
/etc/init.d/ypserv restart
/etc/init.d/yppasswdd restart
12.关闭防火墙
# service iptables stop
13.创建用户
# useradd user1
# useradd user2
14.创建用户密码
# passwd user1
123456
# passwd user2
456789

NIS Client (RHEL4.6)
---------------------------------------------------------
客户端所需的软件包默认是安装的,这里就不用再装了。
1.设置客户端IP地址
# ifconfig eth0 192.168.1.2/24
2.设置host文件
# echo 192.168.1.1 RHEL5.3 >> /etc/hosts
3.建立NIS的域名
# nisdomainname linux
# echo /bin/nisdomainname linux >> /etc/rc.d/rc.local
# echo NISDOMAIN=linux >> /etc/sysconfig/network
4.设置yp.conf配置文件
# echo domain linux server RHEL5.3 >> /etc/yp.conf
5.设置nsswitch.conf文件
# vi /etc/nsswitch.conf
passwd:  files nis
shadow:  files nis
group:  files nis
hosts:  files nis dns
:wq
6.启动ypbind服务程序
启动之前需检查portmap服务是否启动
# service portmap status
# service ypbind start