在虚拟机centos 上mount主机的NFS共享目录。
mount 10.0.2.2:/home/test/share /mnt遇到如下错误:
mount: 10.0.2.2:/home/test/share failed,reason given by server:Permission dened
处理过程如下:
在客户端
1、showmount -e 10.0.2.2 显示正常。说明服务端正常
2、/etc/init.d/portmap status portmap正常运行
portmap(pid 2124) is running ...
3、rpcinfo -p PORTMAP用111端口正常
port
111 portmapper
4、/etc/init.d/nfs status NFS没有运行
rpc.mountd is stopped
nfsd is stopped
rc.rquotad is stopped
5、查看 服务端日志
Jul 19 10:58:44 boydreaming-Latitude-5290 rpc.mountd[8271]: refused mount request from 127.0.0.1 for /home/test/share (/home/test/share): illegal port 37393
在服务端exportfs 加上insecure,使用大于1024的端口。
/home/test/share *(rw,sync,no_subtree_check,no_root_squash,insecure)
exportfs -va
/etc/init.d/nfs-kernel-server restart
客户端mount正常.
总结:可以参看NFS原理详解。有助于理解NFS认证过程。虽然,后来版本升级,命令会有不一样,比如PORTMAP变为RPCBIND,或nfs-kernel-server等,但基本原理相同。
注意,参看man手册,ip地址限制不一定用*通配符。参看系统日志,查看出错。对于主机向虚拟共享来说,如果是NAT模式,它是127.0.0.1而不是同一网段。