#yum install nfs-utils //includes both clientserver pkgs
#chkconfig rpcbind on
#service rpcbind start
#service nfs start && chkconfig nfs on
to configure specific ports for rpc and nfs to listen to =>
#vim /etc/sysconfig/nfs
search for word "PORT" and uncomment them
[root@server5 ~]#service nfs restart
[root@server5 ~]#service nfslock restart //to unlock locked ports if held by clients
to look rpc and nfs services and ports program id
[root@server5 ~]#rpcinfo -p localhost // -p = probe,display list of all registered RPC programmes
if you want to make query from client
[root@Client ~]#/etc/init.d/rpcbind start
[root@Client ~]#rpcinfo -p <nfsserver ip> //to check ports if opened
-----------------------------------------------------------------------------------------------------
now
allow ports through iptables
[root@server5 ~]#iptables -I INPUT -m state --state NEW -p tcp -m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT
[root@server5 ~]#iptables -I INPUT -m state --state NEW -p udp -m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT
OR--------------------------------------
[root@server5 ~]#iptables -N NFS
[root@server5 ~]# iptables -I NFS -m state --state NEW -p tcp -m
multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT
[root@server5 ~]# iptables -I NFS -m state --state NEW -p udp -m
multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT
[root@server5 ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
-------------------------------------------------------------------------------------------------------
#mkdir /nfs_share
#vim /etc/exports //we share nfs directory in this file
/projectx *(rw) // rw export to all clients having our ip access (careful!)
/projecty 192.168..0.100(rw) 192.168.0.101(ro) //rw=readwrite ro=readonly
/shared 192.168.0.103(ro,root_squash) //root_squash= root client cant write and is by default
/nfs_share 192.168.0.100(rw)
----------------------------------------------------------------------------------------------------
[root@server5 ~]#exportfs -r //refresh exports
[root@server5 ~]#exportfs -v //dumps current exports
-----------------------------------------------------------
AT NFS client
[root@Client ~] showmount -e 192.168.0.11 //nfs server ip addr
exportlist for 192.168.0.11
nfs_share *
[root@Client ~]mount -t nfs 192.168.0.11:/nfs_share /shared_data
permanent mount
#vim /etc/fstab
192.168.0.11:/nfs_share /shared_data1 nfs defaults 0 0
192.168.0.11:/nfs_share2 /shared_data2 nfs defaults,soft,time=10,retry=2 0 0
if soft,time=10,retry=2 means any prog trying to access share wont get hang, timeout is 10 sec and retry is 2
check the mounted dir using df -h or mount
------------------------------------------------------------------