Configuring The NIS Server
Install the NIS Server Packages: # yum install ypserv
Edit Your /etc/sysconfig/network File
1 2 |
#/etc/sysconfig/network NISDOMAIN="NIS-name-NETWORK" |
Edit Your /etc/yp.conf File
1 2 |
# /etc/yp.conf - ypbind configuration file ypserver 127.0.0.1 |
Start The Key NIS Server Related Daemons
1 2 3 4 5 6 |
# chkconfig portmap on # chkconfig yppasswdd on # chkconfig ypserv on # service portmap start # service yppasswdd start # service ypserv start |
Check service running correctly
1 |
#rpcinfo -p |
Initialize Your NIS Domain
1 |
# /usr/lib/yp/ypinit -m |
Make sure portmap is running before trying this step
Start The ypbind and ypxfrd Daemons
1 2 3 4 5 |
# chkconfig ypbind on # chkconfig ypxfrd on #service ypbind start # service ypxfrd start |
Again Check service running correctly
1 |
#rpcinfo -p |
Adding New NIS Users
1 2 |
# useradd -g users nisuser # passwd nisuser |
Build NIS User into /var/yp directory
1 2 |
# cd /var/yp # make |
Kiểm tra nisuser có tồn tại trên NIS server chưa?
1 |
# ypmatch nisuser passwd |
Configuring The NIS Client
Configuring The NFS Client (automount /home)
Cần các gói dịch vụ sau: netfs, nfslock (optional), and rpcbind daemons are running. Việc thiết lập NFS server xem hướng dẫn tại đây.
# chkconfig nfslock on
1 2 3 4 5 6 7 8 9 10 |
# chkconfig netfs on # chkconfig <span style="font-family: Arial,sans-serif;">rpcbind</span> on # service <span style="font-family: Arial,sans-serif;">rpcbind</span> start # service netfs start <span style="font-family: Arial,sans-serif;"># service nfslock start</span> <span style="font-family: Arial,sans-serif;">Mount thư mục home từ NFS server về local: </span> Backup thư mục home và tạo thư muc home mới # mv /home /home.save # mkdir /home |
Cần phải cài đặt thêm gói autofs nếu chưa có.
Edit your /etc/auto.master file với line sau :
1 |
<span style="font-family: Arial,sans-serif;">/home /etc/auto.home --timeout 600</span> |
Edit file /etc/auto.home
1 |
* -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp nfs-server<span style="font-family: Arial,sans-serif;">:/home/&</span> |
Đảm bảo autofs running
1 2 |
# chkconfig autofs on <span style="font-family: Arial,sans-serif;"># service autofs restart</span> |
Connect to NIS server
Sử dụng console mode : lưa chọn phương thức NIS , nhập các thông số domain name, server name …
1 |
<span style="font-family: Arial,sans-serif;"># authconfig-tui </span> |
Hoặc config trực tiếp trong các file sau :
1 2 3 4 5 6 7 8 9 |
<span style="font-family: Arial,sans-serif;"># /etc/yp.conf - ypbind configuration file</span> domain NIS-name-NETWORK server nfs-server #/etc/sysconfig/network NISDOMAIN=NIS-name-NETWORK <span style="font-family: Arial,sans-serif;">#/etc/nsswitch.conf</span> passwd: files nis shadow: files nis group: files nis |
Cần bổ sung thêm gói ypbind để kêt nói tới yp server (NIS server):
1 2 3 |
<span style="font-family: Arial,sans-serif;"># yum install ypbind </span> # service ypbind start # chkconfig ypbind on |
Verify Name Resolution
1 2 |
<span style="font-family: Arial,sans-serif;">chỉnh sửa file /etc/hosts để trỏ server name về ip cụ thể </span> 192.168.1.100 <span style="font-family: Arial,sans-serif;"> server name</span> |
Test NIS Access To The NIS Server
You can run the ypcat, ypmatch, and getent commands to make sure communication to the server is correct.
list ra các user trên NIS server
1 |
<span style="font-family: Arial,sans-serif;"># ypcat passwd</span> |
hoặc match trực tiếp 1 nisuser
1 |
<span style="font-family: Arial,sans-serif;"># ypmatch nisuser passwd</span> |
Chú ý: các bước thực hiện trên được thực hiện trên Centos (Server) và Fedora (client). Các bước này có thể thực hiện trên các Distro khác với 1 số thay đổi nhỏ.
Chú ý : việc remote authentication (thông qua LDAP, NIS,… ) có thể conflict với local : nghĩa là user id trên local trùng với user id trên Server . Để xử lý case này phải thay đổi uid hoặc xoá local user .
In /etc/passwd I change the line to look like this “howard:x:1024:1009:Howard ……
In /etc/group I change the line to look like this “howard:x:1009:”
hoặc sử dụng lệnh usermod và groupmod để reset lại uid và gid cho user.
1 2 |
# usermod -u UID -g GID username # groupmod -g GID username (tát nhiên GID phải tồn tại trong hệ thống). |
Hoặc muốn authentication theo thứ tự thì cần config trong file /etc/nsswitch.conf
ví dụ : dưới sẽ theo thứ tự files > nis > ldap
1 2 3 |
passwd: files nis ldap shadow: files nis ldap group: files nis ldap |