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...
3 comments on “NFS: Provide network shares to specific clients
  1. Gerard says:

    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

    • CertDepot says:

      Yes, you are right but this tutorial shows the server side configuration.
      It is clear that the client needs to mount or automount the fs from the NFS server to be able to use it.

  2. wilson says:

    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.

Leave a Reply

Upcoming Events (Local Time)

There are no events.

RHCSA7: Task of the day

Allowed time: 5 minutes.
Add 100MB of swap space to the machine using a new logical volume.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a caching-only DNS server to forward DNS queries.

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