广域网访问NFS

栏目: 服务器 · 发布时间: 6年前

内容简介:原来一直以为NFS服务只能用于局域网,后来看了一些资料,好像是可以在广域网访访问NFS服务,正好手头刚买了一台云服务器,所以就实践验证一下。云服务器使用的是CentOS7.5系统,但默认没有安装NFS服务,所以首先安装并启动服务:[root@linuxidc ~]# yum install nfs-utils

原来一直以为NFS服务只能用于局域网,后来看了一些资料,好像是可以在广域网访访问NFS服务,正好手头刚买了一台云服务器,所以就实践验证一下。

云服务器使用的是CentOS7.5系统,但默认没有安装NFS服务,所以首先安装并启动服务:

[root@linuxidc ~]# yum install nfs-utils

[root@linuxidc ~]# systemctl start nfs

然后创建共享目录,并生成一个测试文件:

[root@linuxidc ~]# mkdir /var/share

[root@linuxidc ~]# echo "hello" > /var/share/test.txt

修改配置文件,设置共享,并重启服务:

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

/var/share *(ro,sync)

[root@linuxidc ~]# systemctl retart nfs

然后在我本地的虚拟机上挂载共享,云服务器的IP为218.98.12.13。虽然没有挂载成功,但错误提示是访问被拒绝,所以看来NFS服务的确是可以跨互联网访问的。

[root@Server ~]# mount -t nfs 218.98.12.13:/var/share /mnt/nfs

mount.nfs: access denied by server while mounting 218.98.12.13:/var/share

百度了一下错误提示,在云服务器上查看日志信息,发现错误原因是客户端使用了无效的端口。

[root@linuxidc ~]# cat /var/log/messages | grep mount

Apr 23 13:22:16 linuxidc rpc.mountd[29798]: refused mount request from 162.232.65.156 for /var/share (/var/share): illegal port 16083

在服务器的配置文件中添加insecure选项,该选项的作用是允许客户端从大于1024的端口发送连接请求,修改完成后重启服务。

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

/var/share *(insecure,ro,sync)

[root@linuxidc ~]# systemctl retart nfs

再次在本地虚拟机上测试,这下成功挂载了:

[root@Server ~]# mount -t nfs 218.98.12.13:/var/share /mnt/nfs

[root@Server ~]# df

文件系统                    1K-块          已用            可用          已用%      挂载点

……

218.98.12.13:/var/share 41152768 1803136 37603328    5% /mnt/nfs

10分钟学会在Ubuntu 18.04 LTS上安装NFS服务器和客户端  https://www.linuxidc.com/Linux/2018-11/155331.htm

Llinux下搭建NFS文件共享服务器  https://www.linuxidc.com/Linux/2018-12/156110.htm

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址: https://www.linuxidc.com/Linux/2019-04/158321.htm


以上所述就是小编给大家介绍的《广域网访问NFS》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Programming in Java

Introduction to Programming in Java

Robert Sedgewick、Kevin Wayne / Addison-Wesley / 2007-7-27 / USD 89.00

By emphasizing the application of computer programming not only in success stories in the software industry but also in familiar scenarios in physical and biological science, engineering, and appli......一起来看看 《Introduction to Programming in Java》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具