本文主要是介绍NFS unmatched host,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在挂载nfs时报错
$ sudo sh mount_tx2.sh
mount.nfs: access denied by server while mounting 192.168.111.177:/home/face
这时就需要知道是什么问题导致了挂载被拒绝,于是去服务端查看错误信息:
$ cat /var/log/syslog | grep mount
Mar 10 19:44:42 face-desktop rpc.mountd[1622]: Version 1.3.3 starting
Mar 10 19:44:42 face-desktop rpc.mountd[1622]: Caught signal 15, un-registering and exiting.
Mar 10 19:44:45 face-desktop rpc.mountd[2013]: Version 1.3.3 starting
Mar 10 19:48:14 face-desktop rpc.mountd[2013]: refused mount request from 10.0.0.4 for /home/face (/home/face): unmatched host
Mar 10 19:56:31 face-desktop rpc.mountd[2013]: refused mount request from 10.0.0.4 for /home/face (/home/face): unmatched host
Mar 10 20:05:48 face-desktop rpc.mountd[2013]: refused mount request from 10.0.0.4 for /home/face (/home/face): unmatched host
Mar 10 20:06:47 face-desktop rpc.mountd[2013]: refused mount request from 10.0.0.4 for /home/face (/home/face): unmatched host
Mar 10 20:13:35 face-desktop rpc.mountd[2013]: refused mount request from 10.0.0.4 for /home/face (/home/face): unmatched host
提示不匹配的主机,在找了半天之后终于找到解决方案.
重新配置/etc/exports, NFS挂载目录及权限都是有/etc/exports文件定义
$sudo vim /etc/exports
比如我要将将我的home目录让所有的IP共享, 则在该文件末尾添加下列语句:
/home/face *(rw,sync,no_root_squash)
修改后的exports文件如下:
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
/home/face *(rw,sync,no_root_squash)
各段表达的意思如下,根据实际进行修改
/home :共享的目录
* :指定哪些用户可以访问* 所有可以ping同该主机的用户192.168.1.* 指定网段,在该网段中的用户可以挂载192.168.1.12 只有该用户能挂载(ro,sync,no_root_squash): 权限(权限参数详解看文章末端)ro : 只读rw : 读写sync : 同步no_root_squash: 不降低root用户的权限
接下来重启nfs服务就可以啦
$ sudo /etc/init.d/nfs-kernel-server restart
[ ok ] Restarting nfs-kernel-server (via systemctl): nfs-kernel-server.service.
这篇关于NFS unmatched host的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!