Debian下NIS服務器安裝配置
Debian下集群構建之------NIS服務器安裝配置
0 網絡拓撲
nis server: 192.168.16.2 nis client: 192.163.16.3
1 服務器端配置
添加測試用戶
$ sudo adduser nistest
軟件安裝
$ sudo aptitude update $ sudo aptitude install nis portmap
NIS 服務的控制
啟動
$ sudo /etc/init.d/nis start
停止
$ sudo /etc/init.d/nis stop
重啟
$ sudo /etc/init.d/nis restart
配置
1. 修改配制文件 /etc/defaultdomain 內容如下, 設定 NIS 的域:
nis
2. 執行
$ sudo domainname nis
3. 修改配置文件 /etc/default/nis 確保有如下設置, 設定為 NIS 主服務器
NISSERVER=master NISCLIENT=true
4. 重啟服務
/etc/init.d/nis restart Starting NIS services: ypserv yppasswdd ypxfrd ypbind
生成映射文件
用戶可以使用 make 命令初始化獨立服務器,建立NIS映射表,文件 /var/yp/Makefile 包含了創建數據庫的命令, 可以通過編輯Makefile指定系統準備分發哪些映射表。比如:
ALL = passwd group hosts rpc services netid protocols netgrp
使用 make 命令初始化獨立服務器
$ cd /var/yp $ sudo make
測試
使用 ypwhich 命令測試與服務器的連接情況
$ ypwhich 192.168.16.2
安全配制
在配置文件 /etc/ypserv.securenets 中,添加可以訪問的客戶機的ip地址范圍,比如允許 192.168.16.0/255.255.255.0 網絡段的所有主機訪問
255.0.0.0 127.0.0.0 255.255.255.0 192.168.16.0
映射文件的訪問控制
可以通過修改主配置文件: /etc/ypserv.conf 來設定對映射文件的訪問權限.
配置文件的語法/格式
<設置項目>:<值><主機名稱/IP>:<網段名稱>:<數據庫類型>:<安全性> * 主機名稱/IP:通常可以這樣設置:192.168.16.0/255.255.255.0,表示192.168.16.0/24整個網段; * 網段名稱:通常設置為*即可; * 數據庫類型:可以使用 '*' 來表示所有類型; * 安全性:主要有三種參數: o none:可以無條件進入本機; o port:僅允許1024以下的端口進入; o deny:不允許其它用戶進入本機;
由于這次的目標比較簡單, 所以所有參數都使用默認設置:
# 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 確保有如下設置,配置為 NIS 客戶端
NISSERVER=falseNISCLIENT=true
2. 在配置文件 /etc/hosts 中添加 NIS 服務器的記錄
192.168.16.2 nisserv
3. 修改 /etc/defaultdomain 內容如下, 設定 NIS 域
nis
4. 執行命令
$ sudo domainname nis
5. 修改配置文件 /etc/yp.conf, 加入如下內容, 指定索要使用的 NIS 服務器
ypserver nisserv
或
ypserver 192.168.16.2
6. 確保配置文件 /etc/nsswitch.conf 中,passwd, group, shadow 和 netgroup 條目如下設置
passwd: compatgroup: compatshadow: compat
7. 在文件 /etc/passwd 尾部加入
+:::::: (6個:)
8. 在文件 /etc/shadow 尾部加入
+:::::::: (8個:)
9. 在文件 /etc/group 尾部加入:
+::: (3個:)
客戶端測試
1. 使用 ypwhich 測試
$ ypwhichnisserv
2. 使用 yptest 測試
$ yptest
3. 使用 ypcat 測試
$ ypcat passwd
3 使用
在客戶端,使用服務器端的測試用戶 nistest 用戶登錄, 系統從 NIS 服務器獲取 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:/$