架设一台NFS服务器,并按照以下要求配置
1、开放/nfs/shared目录,供所有用户查询资料
服务端
[root@localhost ~] vim /etc/exports
-----------------------------------------------
/nfs/shared *(ro)
-----------------------------------------------
[root@localhost ~] mkdir /nfs
[root@localhost ~] mkdir /nfs/shared
[root@localhost ~] touch /nfs/shared/{1..20}
[root@localhost ~] exportfs -ra

客户端
[root@localhost ~] mkdir /nfs/shared
[root@localhost ~] mount 192.168.200.128:/nfs/shared /nfs/shared


2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210
服务端
[root@localhost ~] mkdir /nfs/upload
[root@localhost ~] chmod 777 /nfs
[root@localhost ~] chmod 777 /nfs/upload
[root@localhost ~] vim /etc/exports
-----------------------------------------------------
/nfs/upload 192.168.200.0/24(rw,anonuid=210,anongid=210,all_squash)
-----------------------------------------------------
[root@localhost ~] exportfs -ra
创建相应的用户和用户组
[root@localhost ~] groupadd -g 210 nfs-upload
[root@localhost ~] useradd -u 210 -g nfs-upload nfs-upload
查看用户和用户组的创建情况

客户端
[root@localhost /] mkdir /nfs/shared
[root@localhost /] mkdir /nfs/upload
客户端测试
[root@localhost ~] mount 192.168.200.128:/nfs/upload /nfs/upload
[root@localhost ~] cd /nfs/upload/
[root@localhost upload] touch aaa

3、将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom可以完全访问该目录
服务端
先创建相应用户
[root@localhost ~] useradd tom
[root@localhost ~] chmod 770 /home/tom
[root@localhost ~] vim /etc/exports
----------------------------------------------------------------
/home/tom 192.168.200.129/24(rw,no_all_squash,root_squash)
----------------------------------------------------------------
[root@localhost ~] exportfs -ra
[root@localhost ~] cd /home/tom
[root@localhost ~] touch test
查看改完后tom用户家目录权限

客户端
[root@localhost ~] useradd tom
[root@localhost ~] mkdir /tom
[root@localhost ~] mount 192.168.200.128:/home/tom /tom
最后在客户端进行测试
先用root账户查看/tom【失败】

再用tom账户查看/tom【成功】

662

被折叠的 条评论
为什么被折叠?



