加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

使用 Linux 做 NIS 服务器的设置方法

发布时间:2023-10-04 12:53:33 所属栏目:Linux 来源:
导读:小编收到了很多消息都是关于Linux下的NIS服务器的架设,而对于Linux下NIS服务器的架设相信很多朋友们都不是非常的熟悉,那么我们现在就一起跟小编去看看Linux下怎么架设NIS服务器。实验环境:AS4最小化安装实验目标:

小编收到了很多消息都是关于Linux下的NIS服务器的架设,而对于Linux下NIS服务器的架设相信很多朋友们都不是非常的熟悉,那么我们现在就一起跟小编去看看Linux下怎么架设NIS服务器。

实验环境:AS4最小化安装

实验目标:架设NIS服务器

NIS服务器IP192.168.1.10? hostname = crazylinux.nistest 该服务器下面有mike john2个账号

NIS客户机IP192.168.1.20

NIS初始配置:

首先配置NIS服务器:

1.检查服务器是否安装了下列包:portmap、ypserv、ypbind、yp-tools

ypserv在第一张安装光盘中,

[root@crazylinux cdrom]# mount /media/cdrom/ 挂载

[root@crazylinux /]# rpm -ivh /media/cdrom/RedHat/RPMS/ypserv-2.13-5.i386.rpm

warning: /media/cdrom/RedHat/RPMS/ypserv-2.13-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Preparing...??????????????? ########################################### [100%]

1:ypserv???????????????? ########################################### [100%]

[root@crazylinux /]# rpm -qa | grep portmap

portmap-4.0-63

[root@crazylinux /]# rpm -qa | grep ^yp

yp-tools-2.8-7

ypserv-2.13-5

ypbind-1.17.2-3

2.设置time和time-udp服务的启动状态

[root@crazylinux /]# chkconfig --list | grep time? 默认设置

time-udp:?????? off

daytime-udp:??? off

daytime:??????? off

time:?? off

[root@crazylinux /]# chkconfig time on

[root@crazylinux /]# chkconfig time-udp on

[root@crazylinux /]# service xinetd restart

Stopping xinetd: [? OK? ]

Starting xinetd: [? OK? ]

3.建立NIS的域名

[root@crazylinux /]# nisdomainname nistest

[root@crazylinux /]# cat /etc/rc.d/rc.local

#!/bin/sh

#

# This script will be executed *after* 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/local

/bin/nisdomainname nistest? 添加这行使之开机运行

修改/etc/sysconfig/network文件,增加此行:NISDOMAIN=nistest

4.设置ypserv服务的配置文件

把下面这些添加到/etc/ypserv.conf最后

127.0.0.0/255.255.255.0??? : *?????? : *??????????????? : none

192.168.1.0/255.255.255.0? : *?????? : *??????????????? : none

*?????????????????????? : *?????? : *??????????????? : deny

[root@ crazylinux /]# touch /etc/netgroup

[root@crazylinux /]#hostname crazylinux.nistest

[root@crazylinux /]# cat /var/yp/securenets?? 需要自己建立

host 127.0.0.1

255.255.255.0?? 192.168.1.0

5.启动相关服务:

#service portmap restart

[root@crazylinux /]# service portmap status

portmap (pid 1649) is running...

[root@crazylinux /]# service ypserv start

Starting YP server services: [? OK? ]

[root@crazylinux /]# service yppasswdd start

Starting YP passwd service: [? OK? ]

[root@crazylinux /]# chkconfig --level 35 ypserv on

[root@crazylinux /]# chkconfig --level 35 yppasswdd on? 设置开机自动运行

6.初始化NIS数据库:

[root@crazylinux /]# useradd user1

[root@crazylinux /]# passwd user1

#/usr/lib/yp/ypinit –m

此时会询问是否有其他NIS服务器,如果没有,则可以直接按Ctrl+D结束,并重启ypserv服务。

#service ypserv restart

#service yppasswdd restart

同时检查进程是否正常运行以及信息是否正确:ps –aux | grep yp???? tail /var/log/message

以下进行客户端上的配置:

1.确认安装以下包: ypbind、yp-tools默认安装了的

2.设置hosts文件

[root@localhost ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1?????????????? localhost.localdomain localhost

192.168.1.10??????????? crazylinux??? NIS服务器的主机名

3.建立NIS域名

[root@crazylinux /]# nisdomainname nistest

[root@crazylinux /]# cat /etc/rc.d/rc.local

#!/bin/sh

#

# This script will be executed *after* 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/local

/bin/nisdomainname nistest? 添加这行使之开机运行

修改/etc/sysconfig/network文件,增加此行:NISDOMAIN=nistest

4.设置yp.conf

[root@localhost ~]# cat /etc/yp.conf

# generated by /sbin/dhclient-script

domain domain.org broadcast

domain? nistest???? 添加这句

ypserver crazylinux.nistest

在/etc/passwd最下面添加

+::::::

5.设置nsswitch.conf

vi? /etc/nsswitch.conf?? 修改为这样

passwd:???? files nis nisplus

shadow:???? files nis nisplus

group:????? files nis nisplus

#hosts:???? db files nisplus nis dns

hosts:????? files nis dns

6.启动ypbind服务程序

[root@localhost ~]# service portmap status

portmap (pid 1683) is running...

[root@localhost ~]# service? ypbind start

Binding to the NIS domain: [? OK? ]

Listening for an NIS domain server..

在NIS服务器中输出NFS共享目录

在nis服务器上

[root@localhost ~]# vi /etc/exports 添加

/home???? 192.168.1.0/24(rw,async,np_root_squash)

[root@localhost ~]#service nfs start

在NIS客户机上

[root@localhost ~]#vi /etc/fstab

Crazylinux.nistest:/home/?????? /home???? nfs?? defaults?? 0???? 0

现在在客户机中用服务器里面的帐号登陆? 嘿嘿? OK

上文中介绍的Linux下如何架设NIS服务器的内容你学会了吗?linux系统还有更多丰富的功能和特性,可以帮助我们提高工作学习效率,有待朋友们多多发掘。

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章