Server Side
Disable SeLinux
Edit the configuration file:vi /etc/selinux/config
Modify as follows:
#SELINUX=enforcing # Comment out #SELINUXTYPE=targeted # Comment out SELINUX=disabled # Add this line
Then reboot the system:
reboot # Restart the system
Create a Directory
Using the root user, create a directory named/nfs
. Note: It’s best to check which partition has the most space by runningdf
, as the root (/
) partition may not have the most space. In some automatic partitioning setups, the/home
partition may have the most space.Install NFS Utilities and RPC Bind
yum -y install nfs-utils rpcbind
Enable Services at Boot
chkconfig nfs on chkconfig rpcbind on chkconfig nfslock on
Configure Exports
Edit the NFS exports file:vi /etc/exports
Add the following line:
/home/nfs 192.168.1.0/24(rw,sync,no_all_squash)
Start NFS Services
service rpcbind start service nfs start service nfslock start exportfs -a
Configure NFS Ports
Edit the NFS configuration file:vi /etc/sysconfig/nfs
Uncomment the following lines:
LOCKD_TCPPORT=32803 LOCKD_UDPPORT=32769 MOUNTD_PORT=892
Restart NFS Services
service rpcbind restart service nfs restart service nfslock restart
Verify RPC Services
rpcinfo -p localhost
Note down the ports and their types.
Configure Firewall Rules
Adjust the IP range according to your network: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
Save Firewall Rules
Test from the client side. If successful, save the iptables configuration:service iptables save
Client Side
Create Mount Point
mkdir /nfs
Check RPC Services on Server
rpcinfo -p [server_ip]
Show NFS Exports
showmount -e [server_ip]
Mount NFS Share
mount -t nfs -o soft,intr,bg,rw [server_ip]:/home/nfs /nfs
Unmount NFS Share
umount /nfs
Configure Automatic Mounting
Edit the fstab file:vi /etc/fstab
Add the following line:
[server_ip]:/home/nfs /nfs nfs soft,intr,bg,rw 0 0