NFS: Provide network shares to specific clients

Share this link

Install the NFS packages:

# yum groupinstall -y "NFS file server"

Add new rules to the firewall:

# iptables -I INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT

Save the firewall configuration:

# service iptables save

Activate the NFS services at boot:

# chkconfig rpcbind on
# chkconfig nfs on
# chkconfig nfslock on

Start the NFS services:

# service rpcbind start
# service nfs start
# service nfslock start

Create directories to export and assign access rights:

# mkdir -p /home/tools
# chmod 777 /home/tools
# mkdir -p /home/guests
# chmod 777 /home/guests

Edit the /etc/exports file and add the following lines with the name (or IP address) of the client(s):

/home/tools client1(rw,no_root_squash)
/home/guests client2(rw,no_root_squash)

Note: Please, don’t put any space before the open parenthesis, this would completely change the meaning of the line!

Export the directories:

# exportfs -avr

Note: On the client side, the commands are:

# yum install -y nfs-utils
# mount -t nfs server:/home/tools /mnt
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Leave a Reply

Please Login to comment
2 Comment threads
1 Thread replies
Most reacted comment
Hottest comment thread
3 Comment authors
wilsonCertDepotGerard Recent comment authors
newest oldest
Notify of

Thanks for creating this tutorial.

I thought that the remote file system needed to be mounted on the client end

for example:
[root@client2]# mount -t nfs host:/home/guests/ /shared


A major source of confusion for many people is whether it is still necessary to go into /etc/sysconfig/nfs and specify ports for mountd, lockd, and statd, and then update the iptables rules with these ports.

This is only necessary if you are running NFSv2 or v3.

As specified in this guide, one only needs to open tcp-111, udp-111, and tcp-2049 when running NFSv4 on RHEL6.

Upcoming Events (Local Time)

There are no events.

RHCSA7: Task of the day

Allowed time: 3 minutes.
Check that you've got no SELinux policy violations.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a default secure MariaDB database called maria and create a table named people with two columns respectively name varchar(20) and age int(10) unsigned.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...