Install server is very easy. We just use yum command to find necessary libraries and install automatically.
[nick1811@NAS ~]$ sudo yum install nfs-utils nfs-utils-libCreate white list. We allows all IP in subnetwork(192.168.0.*). And all users have access right for read and write.
[nick1811@NAS ~]$ vim /etc/exports /home/nick1811/Shared_Folder 192.168.0.1/24(rw)Run several startup scripts for the NFS server
[nick1811@NAS ~]$ sudo service rpcbind start [nick1811@NAS ~]$ sudo service nfs startFinally, remember turn on the port in iptables.
[nick1811@NAS ~]$ sudo vim /etc/sysconfig/iptables
# NFS -A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
[nick1811@NAS ~]$ sudo service iptables restart iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules:
Although we have been set complete. But how to check all setting are correctly? To reach this purpose. I choose other CentOS and install NFS client to do it.
First, we also need to install necessary libraries.
[nick1811@Client ~]$ sudo yum install nfs-utils nfs-utils-libSecond, we use showmount command to check we can see the shared folder.
[nick1811@Client ~]$ showmount -e 192.168.0.1 Export list for 192.168.0.1: /home/nick1811/Shared_Folder 192.168.0.1/24Finally, we mount shared folder to local folder which is we created.
[nick1811@Client ~]$ mount 192.168.0.1:/home/nick1811/Shared_Folder /mnt/nfsWhen we can put files to /mnt/nfs and we can see files on the server side, we successfully setup NFS server.
Reference: http://linux.vbird.org/linux_server/0330nfs.php