NFS (Network File System) is basically developed for sharing of files and folders between Linux/Unix systems by Sun Microsystems in 1980. It allows you to mount your local file systems over a network and remote hosts to interact with them as they are mounted locally on the same system. With the help of NFS, we can set up file sharing between Unix to Linux system and Linux to Unix system.
Benefits of NFS:
NFS allows local access to remote files.
It uses standard client/server architecture for file sharing between all *nix based machines.
With NFS it is not necessary that both machines run on the same OS.
With the help of NFS we can configure centralized storage solutions.
Users get their data irrespective of physical location.
No manual refresh needed for new files.
Newer version of NFS also supports acl, pseudo root mounts.
Can be secured with Firewalls and Kerberos.
How to configure Iptables for NFS Server.
How to share Home Directory
=====================================================
Server Configuration
service rpcbind start
rpcinfo # port 111 has to run
yum -y install nfs-utils nfs-utils-lib
service nfs start
chkconfig rpcbind on
chkconfig nfs on
vi /etc/sysconfig/nfs
Un-comment the following lines and save the file.
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
service rpcbind restart
service nfs restart
#https://mcdee.com.au/tutorial-configure-iptables-for-nfs-server-on-centos-6/
iptables -I INPUT -m state --state NEW -p tcp \
-m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT
iptables -I INPUT -m state --state NEW -p udp \
-m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT
service iptables save
chkconfig iptables on
Centos7
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --reload
OR
service iptables stop
chkconfig iptables off
mkdir /adminNFS
cd /adminNFS
vi how_to_config_nfs #create some file
vi /etc/exports
/adminNFS *(ro,sync)
service nfs restart
exportfs -v # to see what we sharing
NFS Client Configuration
yum -y install nfs-utils nfs-utils-lib
showmount -e 192.168.0.101 or NFS
mkdir /nfs-share
mount 192.168.0.101:/adminNFS /nfs-share
df
cd /nfs-share
ls
#Permanent mount
vi /etc/fstab
192.168.0.101:/adminNFS nfs-share nfs defaults 0 0
Automount Users home directory
Server
useradd slavik
vi /etc/exports
/home *(rw,no_root_squash,no_subtree_check,sync)
exportfs -r #rewrite update
exportfs -v
Client
showmount -e 192.168.0.101
yum install autofs -y
mkdir /mnt/nfs/home
mount 192.168.0.101:/home /mnt/nfs/home
vi /etc/auto.master
/home /etc/auto.home
vi /etc/auto.home
* 192.168.0.101:/home/&
service autofs restart
=====================================================
Autofs Automount link Different way:
http://www.elinuxbook.com/how-to-configure-autofs-automount-in-linux/