关闭linux nfs共享检测漏洞,Linux的NFS共享

实验02:NFS共享

实验目标

通过下面几个实验了解NFS共享的设置与排错。

实验步骤

实验一:

将/root 共享给192.168.10.20,可写、同步,允许客户机以root权限访问

1.NFS服务端操作:

[root@dhcpser ~]#vim/etc/exports

/root   192.168.10.20(rw,sync,no_root_squash)

[root@dhcpser ~]# service portmap restart//启动nfs前置服务

[root@dhcpser ~]# service nfs restart//

[root@dhcpser ~]# chkconfig portmap on//设置开机启动

[root@dhcpser ~]# chkconfig nfs on

2.NFS客户端操作:

[root@localhost ~]# service portmap restart

[root@localhost ~]# showmount -e 192.168.10.253

Export list for 192.168.10.253:

/root    192.168.10.20

[root@localhost ~]# mkdir -p /data/root/

[root@localhost ~]# mount 192.168.10.253:/root/ /data/root/

[root@localhost ~]# df -hT | grep nfs

nfs     19G  2.7G   16G  15% /data/root

[root@localhost ~]# cd /data/root/

[root@localhost root]# touch file1.txt

[root@localhost root]# ls -l file1.txt

-rw-r--r-- 1 root root 0 06-12 17:18 file1.txt

验证:

[root@dhcpser ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:65:AF:49

inet addr:192.168.10.253  Bcast:192.168.10.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe65:af49/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:216 errors:0 dropped:0 overruns:0 frame:0

TX packets:329 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:31242 (30.5 KiB)  TX bytes:47404 (46.2 KiB)

[root@dhcpser ~]# route -n

Kernel IP routing table

Destination     Gateway       Genmask      Flags MetricRef  Use Iface

192.168.10.0    0.0.0.0          255.255.255.0  U     00            0 eth0

169.254.0.0      0.0.0.0          255.255.0.0      U     00            0 eth0

0.0.0.0        192.168.10.254  0.0.0.0             UG    00           0 eth0

[root@dhcpser ~]# hostname

Dhcpser.tarena.com

实验二:

将/usr/src 共享给192.168.10.0/24网段,可写、异步

NFS服务端操作:

[root@dhcpser ~]# cat /etc/exports

/root   192.168.10.20(rw,sync,no_root_squash)

/usr/src        192.168.10.0/24(rw,async)

[root@dhcpser ~]# exportfs -rv//这个也是重启服务

[root@dhcpser ~]# setfacl -m u:nfsnobody:rwx /usr/src/

NFS客户端操作:

[root@localhost ~]# mkdir /data/src/

[root@localhost ~]# showmount -e 192.168.10.253

Export list for 192.168.10.253:

/root    192.168.10.20

/usr/src 192.168.10.0/24

[root@localhost ~]# mount 192.168.10.253:/usr/src/ /data/src/

[root@localhost ~]# cd /data/src/

[root@localhost src]# touch file1.txt

验证:

[root@localhost src]# ls -l file1.txt

-rw-r--r-- 1 nfsnobody nfsnobody 0 06-12 17:23 file1.txt

实验三:

在上一个实验基础上实现客户端上面所有用户身份都映射成nfsnobody

NFS服务端操作:

[root@dhcpser ~]# chmod o+w /usr/src/

NFS客户端操作:

[root@localhost ~]# useradd tom

[root@localhost ~]# su - tom

[tom@localhost ~]$ cd /data/src/

[tom@localhost src]$ touch tom1.txt

[tom@localhost src]$ ls -l tom1.txt

-rw-rw-r-- 1 tom tom 0 06-12 17:29 tom1.txt

再来修改NFS主配置文件

[root@dhcpser ~]# cat /etc/exports

/root   192.168.10.20(rw,sync,no_root_squash)

/usr/src        192.168.10.0/24(rw,async,all_squash)

[root@dhcpser ~]# exportfs -rv

验证:NFS客户端

[tom@localhost src]$ touch tom2.txt

[tom@localhost src]$ ls -l tom2.txt

-rw-rw-r-- 1 nfsnobody nfsnobody 0 06-12 17:31 tom2.txt

实验四:

在客户端实现开机自动挂载NFS服务器共享的/root目录到本地/data/root

在客户端实现触发挂载NFS服务器共享的/usr/src目录到本地/data/src

[root@localhost ~]#vim/etc/fstab

192.168.10.253:/root   /data/root    nfs     defaults,_netdev       0 0

[root@localhost ~]#vim/etc/auto.master

/mnt   /etc/auto.data

[root@localhost ~]#vim/etc/auto.data

src     -fstype=nfs,rw  192.168.10.253:/usr/src

[root@localhost ~]# service autofs restart

[root@localhost ~]# chkconfig autofs on

问题和经验总结

共享文件的实际权限是共享权限和Linux文件权限取交集

故障现象:自动挂载测试

解决办法:只挂载设备或者只挂载目录,看看是否能挂上

故障现象: 客户端无法进入共享文件

解决办法:可能是服务器的服务未重启

故障现象:系统关机后服务不存在

解决办法:需要设置开机重启服务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值