• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
OpenTechTips

OpenTechTips

Comprehensive IT Guides for Pros and Enthusiasts

MENUMENU
  • HOME
  • ALL TOPICS
    • Exchange
    • InfoSec
    • Linux
    • Networking
    • Scripting
      • PowerShell
    • SSL
    • Tools
    • Virtualization
    • Web
    • Windows
  • ABOUT
  • SUBSCRIBE
Home » How to Configure NFSv4 and NFSv3 on CentOS?

How to Configure NFSv4 and NFSv3 on CentOS?

August 14, 2020 - by Zsolt Agoston - last edited on August 14, 2020

Installing an NFS file server on linux mainly consists of three short steps: install the NFS package, then configure (or in another words export) the NFS shares and lastly set the built-in firewall to allow incoming NFS queries.

1. Install NFS on CentOS

# The nfs-utils package contains the nfs server, also the client binaries
yum install -y nfs-utils

# Start and enable the NFS services
systemctl start nfs-server rpcbind
systemctl enable nfs-server rpcbind

2. Configure our NFS share

# Create the directory that will be exported as NFS share
mkdir /NFSShare

# Set read-write access for Everyone on it
chmod 777 /NFSShare

# Export the directory as NFS share, add the following line to the /exports file
vi /etc/exports

The /etc/exports file:

/NFSShare    *(rw,sync,no_root_squash)

*:                     allow all hosts to connect to the share. If you want to specify different rules for different clients, simply create a separate line for each, using the IP address of the client instead of the asterisk character /NFSShare:     the shared directory that will be remotely accessible rw:                   writable permission to the folder sync:                all changes to the files are flushed immediately to disk. This makes the process a little slower, but more stable no_root_squash: root on the client machine will have root access on the NFS shared files instead of handled as user 'nobody'

# Re-export the NFS shares after editing the /etc/exports file
exportfs -r

3. Allow NFS on the server's firewall

NFSv4 uses only one port 2049/tcp that makes if easy to configure the firewall on the linux server. On the other hand, NFSv3 also needs 111 tcp and upd, and higher ports also be opened, to open them we issue the following commands:

# Firewall rules for NFSv4
firewall-cmd --permanent --add-service nfs
firewall-cmd --reload

# Firewall rules for NFSv3
firewall-cmd --permanent --add-service nfs
firewall-cmd --permanent --add-service mountd
firewall-cmd --permanent --add-service rpc-bind
firewall-cmd --reload

4. Connect to the share from a client

# Mount the NFS share using nfs version 4 (default)
[root@client ~]# mount -t nfs -o vers=4 10.0.1.200:/NFSShare /NFSmounted

# Mount the NFS share using nfs version 3 (older, but required by legacy systems)
[root@client ~]# mount -t nfs -o vers=3 10.0.1.200:/NFSShare /NFSmounted
How to Configure NFSv4 and NFSv3 on CentOS?

Reader Interactions

Comments Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tools

Secondary Sidebar

CONTENTS

  • 1. Install NFS on CentOS
  • 2. Configure our NFS share
  • 3. Allow NFS on the server’s firewall
  • 4. Connect to the share from a client

  • Terms of Use
  • Disclaimer
  • Privacy Policy
Manage your privacy

To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site and show (non-) personalized ads. Not consenting or withdrawing consent, may adversely affect certain features and functions.

Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.

Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}
Manage your privacy
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}