Debian下NIS服務(wù)器安裝配置
Debian下集群構(gòu)建之------NIS服務(wù)器安裝配置
0 網(wǎng)絡(luò)拓?fù)?
nis server: 192.168.16.2 nis client: 192.163.16.3
1 服務(wù)器端配置
添加測(cè)試用戶
$ sudo adduser nistest
軟件安裝
$ sudo aptitude update $ sudo aptitude install nis portmap
NIS 服務(wù)的控制
啟動(dòng)
$ sudo /etc/init.d/nis start
停止
$ sudo /etc/init.d/nis stop
重啟
$ sudo /etc/init.d/nis restart
配置
1. 修改配制文件 /etc/defaultdomain 內(nèi)容如下, 設(shè)定 NIS 的域:
nis
2. 執(zhí)行
$ sudo domainname nis
3. 修改配置文件 /etc/default/nis 確保有如下設(shè)置, 設(shè)定為 NIS 主服務(wù)器
NISSERVER=master NISCLIENT=true
4. 重啟服務(wù)
/etc/init.d/nis restart Starting NIS services: ypserv yppasswdd ypxfrd ypbind
生成映射文件
用戶可以使用 make 命令初始化獨(dú)立服務(wù)器,建立NIS映射表,文件 /var/yp/Makefile 包含了創(chuàng)建數(shù)據(jù)庫(kù)的命令, 可以通過(guò)編輯Makefile指定系統(tǒng)準(zhǔn)備分發(fā)哪些映射表。比如:
ALL = passwd group hosts rpc services netid protocols netgrp
使用 make 命令初始化獨(dú)立服務(wù)器
$ cd /var/yp $ sudo make
測(cè)試
使用 ypwhich 命令測(cè)試與服務(wù)器的連接情況
$ ypwhich 192.168.16.2
安全配制
在配置文件 /etc/ypserv.securenets 中,添加可以訪問(wèn)的客戶機(jī)的ip地址范圍,比如允許 192.168.16.0/255.255.255.0 網(wǎng)絡(luò)段的所有主機(jī)訪問(wèn)
255.0.0.0 127.0.0.0 255.255.255.0 192.168.16.0
映射文件的訪問(wèn)控制
可以通過(guò)修改主配置文件: /etc/ypserv.conf 來(lái)設(shè)定對(duì)映射文件的訪問(wèn)權(quán)限.
配置文件的語(yǔ)法/格式
<設(shè)置項(xiàng)目>:<值><主機(jī)名稱/IP>:<網(wǎng)段名稱>:<數(shù)據(jù)庫(kù)類型>:<安全性> * 主機(jī)名稱/IP:通??梢赃@樣設(shè)置:192.168.16.0/255.255.255.0,表示192.168.16.0/24整個(gè)網(wǎng)段; * 網(wǎng)段名稱:通常設(shè)置為*即可; * 數(shù)據(jù)庫(kù)類型:可以使用 '*' 來(lái)表示所有類型; * 安全性:主要有三種參數(shù): o none:可以無(wú)條件進(jìn)入本機(jī); o port:僅允許1024以下的端口進(jìn)入; o deny:不允許其它用戶進(jìn)入本機(jī);
由于這次的目標(biāo)比較簡(jiǎn)單, 所以所有參數(shù)都使用默認(rèn)設(shè)置:
# Host : Domain : Map : Security # # * : * : passwd.byname : port/mangle # * : * : passwd.byuid : port/mangle # This is the default - restrict access to the shadow password file, # allow access to all others. * : * : shadow.byname : port * : * : passwd.adjunct.byname : port * : * : * : none
2 客戶端配置
軟件安裝
$ sudo aptitude update$ sudo aptitude install nis portmap
配置
1. 修改配置文件 /etc/default/nis 確保有如下設(shè)置,配置為 NIS 客戶端
NISSERVER=falseNISCLIENT=true
2. 在配置文件 /etc/hosts 中添加 NIS 服務(wù)器的記錄
192.168.16.2 nisserv
3. 修改 /etc/defaultdomain 內(nèi)容如下, 設(shè)定 NIS 域
nis
4. 執(zhí)行命令
$ sudo domainname nis
5. 修改配置文件 /etc/yp.conf, 加入如下內(nèi)容, 指定索要使用的 NIS 服務(wù)器
ypserver nisserv
或
ypserver 192.168.16.2
6. 確保配置文件 /etc/nsswitch.conf 中,passwd, group, shadow 和 netgroup 條目如下設(shè)置
passwd: compatgroup: compatshadow: compat
7. 在文件 /etc/passwd 尾部加入
+:::::: (6個(gè):)
8. 在文件 /etc/shadow 尾部加入
+:::::::: (8個(gè):)
9. 在文件 /etc/group 尾部加入:
+::: (3個(gè):)
客戶端測(cè)試
1. 使用 ypwhich 測(cè)試
$ ypwhichnisserv
2. 使用 yptest 測(cè)試
$ yptest
3. 使用 ypcat 測(cè)試
$ ypcat passwd
3 使用
在客戶端,使用服務(wù)器端的測(cè)試用戶 nistest 用戶登錄, 系統(tǒng)從 NIS 服務(wù)器獲取 nistest 用戶的信息, 登錄成功:
debian login: nistestPassword:Linux debian 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686The programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.No directory, logging in with HOME=/nistest@debian:/$