Wednesday, August 27, 2014

How to Install & Run NFS Server with Fixed Ports

Important Files for NFS Configuration
/etc/exports : Its a main configuration file of NFS, all exported files and directories are defined in this file at the NFS Server end.
/etc/fstab : To mount a NFS directory on your system across the reboots, we need to make an entry in /etc/fstab.
/etc/sysconfig/nfs : Configuration file of NFS to control on which port rpc and other services are listening.

NFS Default Ports
111  NFS
2049 Portmap


Install Server with below command
yum install nfs-utils nfs-utils-lib


Start the service & add in startup
/etc/init.d/nfs start
chkconfig nfs on

Edit file to share directory
vi /etc/exports

To share with all
/home/shared *(rw,sync)

To share with particular IP
/home/shared  172.39.253.10(rw,sync)

Important NFS Sharing Options
Some other options we can use in /etc/exports file for file sharing is as follows.
ro: With the help of this option we can provide read only access to the shared files i.e client will only be able to read.
rw: This option allows the client server to both read and write access within the shared directory.
sync: Sync confirms requests to the shared directory only once the changes have been committed.
no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
no_root_squash: This phrase allows root to connect to the designated directory.


Need to run the below command to export directory after adding in exports file
exportfs -a
 
After changing in exports file run below command to share again (Only required once you shared new directory or changed permission in exports file)
exportfs -r
 
To check files
exportfs -v
 ................................................................................
Client machine
yum install nfs-utils nfs-utils-lib

Start the service & add in startup
/etc/init.d/nfs start
chkconfig nfs on

Run the below command to check shared directory
showmount -e Server-IP

To mount share directory
mount 172.39.253.28:/home/Shared /mnt

Check mount directory
mount | grep nfs

To mount on reboot
172.39.253.28:/home/Shared /mnt  nfs defauls 0 0
 ........................................................................................

 IMPORTANT
Allow NFS with Fixed ports  on Server

Please add the following lines in  /etc/sysconfig/nfs configuration file on server. Any free port may be specified.
LOCKD_TCPPORT=33776
LOCKD_UDPPORT=33776
MOUNTD_PORT=33777
STATD_PORT=33778
RQUOTAD_PORT=33779
RPCNFSDCOUNT=32

Allow above ports on iptables with default 111 & 2049 ports

Restart NFS service
# service nfs restart
# service nfslock restart

No comments:

Post a Comment