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)
Loading...

Leave a Reply

3 Comments on "NFS: Provide network shares to specific clients"

Notify of
Sort by:   newest | oldest
Gerard
Guest
Gerard

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

wilson
Member
wilson

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.

wpDiscuz

RHCSA7: Task of the day

Allowed time: 8 minutes.
Find all files bigger than 100MB and write their names into the /root/results.txt file.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a default secure MariaDB database called maria and back up the database with mysqldump.

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 ...

Recent Comments