服务端Linux版本:Redhat6.5 客户端Linux版本:centos7 一、服务端配置 1.检查本机是否安装nfs服务 #rpm -qa nfs-utils rpcbind

2.安装程序包 #yum install nfs-utils rpcbind -y

3.创建共享文件夹 #mkdir -p /home/nfstest

4.修改配置文件 #vim /etc/exports 在文件中添加以下内容 /home/nfstest 192.168.57.129(rw,sync,insecure,no_subtree_check,no_root_squash)

5.查看服务用的端口 #rpcinfo -p

6.修改默认端口 #vim /etc/sysconfig/nfs 在文件中添加一下内容 RQUOTAD_PORT=30001 LOCKD_TCPPORT=30002 LOCKD_UDPPORT=30002 MOUNTD_PORT=30003 STATD_PORT=30004

7.重启rpcbind和nfs #service rpcbind restart #service nfs restart

8.添加防火墙规则 #vi /etc/sysconfig/iptables 在文件中添加以下内容

nfs

-A INPUT -p tcp -s 192.168.57.129/24 --dport 111 -j ACCEPT -A INPUT -p udp -s 192.168.57.129/24 --dport 111 -j ACCEPT -A INPUT -p tcp -s 192.168.57.129/24 --dport 2049 -j ACCEPT -A INPUT -p udp -s 192.168.57.129/24 --dport 2049 -j ACCEPT -A INPUT -p tcp -s 192.168.57.129/24 --dport 30001:30004 -j ACCEPT -A INPUT -p udp -s 192.168.57.129/24 --dport 30001:30004 -j ACCEPT -A INPUT -p tcp -s 192.168.57.130/24 --dport 111 -j ACCEPT -A INPUT -p udp -s 192.168.57.130/24 --dport 111 -j ACCEPT -A INPUT -p tcp -s 192.168.57.130/24 --dport 2049 -j ACCEPT -A INPUT -p udp -s 192.168.57.130/24 --dport 2049 -j ACCEPT -A INPUT -p tcp -s 192.168.57.130/24 --dport 30001:30004 -j ACCEPT -A INPUT -p udp -s 192.168.57.130/24 --dport 30001:30004 -j ACCEPT

END

9.重启防火墙 #service iptables restart

10.本机查看 #showmount -e localhost

11.设置开机自启 #chkconfig nfs on #chkconfig rpcbind on

二、客户端配置 1.安装服务 #yum install nfs-utils rpcbind -y

2.查看共享 #showmount -e 192.168.57.130

3.创建共享文件夹 #mkdir -p /home/nfstest

4.挂载 #mount 192.168.57.130:/home/nfstest /home/nfstest

5.确认挂载 #tail -1 /etc/mtab

6.测试

7.设置开机自起 #chkconfig nfs on #chkconfig rpcbind on