2009年10月18日 星期日

CentOS建立NIS

NIS(Network Information Server)
目的:統一帳號認證資料於一部主機
伺服器名稱:Yellow Page

相關請參CentOS NIS配合NFS

需用軟體:
  • yp-tools-2.9-0.1 (Server,Client都需要)
    ypbind-1.19-11.el5 (Server,Client都需要)
    ypserv (NIS server,Server裝即可)

環境設定--NIS Server:


  • #vi /etc/hosts
    • 127.0.0.1               localhost.localdomain localhost master.net98
      ::1             localhost6.localdomain6 localhost
      140.137.217.94 master.net98
      140.137.217.84 client.net98
  • #nisdomainname net98
  • #vi /etc/sysconfig/network




    NETWORKING=yes
    NETWORKING_IPV6=no
    HOSTNAME=localhost.localdomain
    NISDOMAIN=net98


環境設定--NIS Client:

  • #vi /etc/hosts
    • 127.0.0.1               localhost.localdomain localhost client.net98
    • ::1             localhost6.localdomain6 localhost
    • 140.137.217.94 master.net98
    • 140.137.217.84 client.net98
建立NIS server
  • 建立測試帳號
    • #groupadd test
    • #useradd -g test -m jeff
    • #passwd jeff
  • 設定NIS Server設定檔
    • #vi /etc/ypserv.conf --->取消最後一行的#
    • # If you have maps with YP_SECURE or YP_AUTHDES, you should create
      # a rule for them above, that's much faster.
       *                        : *       : *                : none
  • 啟動各項服務
    • #netstat -tanlp | grep :111 --->確認rpcbind(portmap) 有啟動
    • #service ypserv restart --->啟動 ypserv
    • #service yppasswdd restart --->啟動 yppasswdd (可遠端修改密碼的功能) 
    • #rpcinfo -p localhost --->檢查本機上rpc的狀況
  • 建立NIS map(資料庫查詢格式) --->將帳號相關檔放到/var/yp/網域/
    • # /usr/lib/yp/ypinit -m
    • At this point, we have to construct a list of the hosts which will run NIS
    • servers.  localhost.localdomain is in the list of NIS server hosts.  Please continue to add
    • the names for the other hosts, one per line.  When you are done with the
    • list, type a <control D>.--->要退出時打ctrl+D
    •         next host to add:  localhost.localdomain
    •         next host to add:  master.net98--->新增
    •         next host to add:
    • The current list of NIS servers looks like this:
    • localhost.localdomain
    • master.net98
    • Is this correct?  [y/n: y]  y--->確認
  • 測試--確認server是否己架設ok
    • # ypcat -h localhost passwd.byname --->localhost為主機名稱,不可用ip
    • jeff:$1$Cgv6Ls9G$vM79eQDEcmRq4zl1Xe3t1.:500:500::/home/jeff:/bin/bash


NIS Client驗證
以下工具都是去修改/etc/nsswitch.conf和/etc/yp.conf

以OpenSuse為client做測試
 #yast




















現在可以利用遠端連線或按F1~F6換到登入模式利用jeff帳號登入來試試

以CentOS為client做測試
 #LANG=C
 #authconfig-tui












沒有留言:

張貼留言