Network File System (NFS) is a distributed filesystem protocol that allows RHEL 8 servers to export directories over the network so that client machines can mount and use them as if they were local storage. NFS is a cornerstone of Linux infrastructure, used in everything from home lab setups to large-scale HPC clusters and virtualization environments. This tutorial covers installing NFS server and client packages, configuring an export, enabling the service through firewalld, and mounting the share on a client both manually and persistently via /etc/fstab. All commands assume root or sudo access on RHEL 8.

Prerequisites

  • Two RHEL 8 systems on the same network: one server, one client
  • Root or sudo access on both machines
  • A shared directory to export (e.g., /srv/share)
  • Network connectivity confirmed with ping between the two hosts
  • SELinux in enforcing mode (default on RHEL 8)

Step 1 — Install NFS Utilities and Create the Export Directory

The nfs-utils package provides both server and client NFS tools. Install it on the server first, then create and populate the directory you intend to share. Setting correct ownership ensures users can read and write through the NFS mount.

dnf install -y nfs-utils

mkdir -p /srv/share
chown nobody:nobody /srv/share
chmod 0777 /srv/share

# Verify the directory
ls -ld /srv/share

Using nobody:nobody ownership is appropriate for public shares. For production environments, set ownership to a specific service account and tighten permissions accordingly.

Step 2 — Configure the NFS Export

NFS exports are defined in /etc/exports. Each line specifies a path, a client or network allowed to access it, and options in parentheses. The rw option allows read-write access, sync ensures writes are flushed to disk before the server acknowledges them, and no_subtree_check disables subtree checking to improve reliability.

# Edit /etc/exports and add the following line
# Replace 192.168.1.0/24 with your actual client subnet
echo '/srv/share  192.168.1.0/24(rw,sync,no_subtree_check)' >> /etc/exports

# Apply the export configuration
exportfs -arv

# Verify active exports
exportfs -v

The exportfs -arv command re-reads /etc/exports and broadcasts changes without restarting the NFS server. Any syntax errors in the file will be reported at this step.

Step 3 — Enable and Start the NFS Server Service

On RHEL 8, the NFS server is managed by nfs-server.service. Enable it at boot and start it immediately. The service also starts dependent units such as rpcbind and nfs-mountd automatically.

systemctl enable --now nfs-server
systemctl status nfs-server

# Confirm RPC services are registered
rpcinfo -p localhost

Step 4 — Open the Firewall for NFS

NFSv4 requires the nfs service in firewalld. For NFSv3 compatibility (used by older clients and the showmount command), you must also open mountd and rpc-bind. Add all three to the permanent firewalld configuration and reload.

firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --reload

# Verify active services
firewall-cmd --list-services

Step 5 — Mount the Share on the Client

Switch to the client machine. Install nfs-utils there as well, then use showmount to list what the server is exporting. Mount the share manually first to confirm connectivity before making it persistent.

# On the CLIENT machine
dnf install -y nfs-utils

# List exports from the server (replace 192.168.1.10 with your server IP)
showmount -e 192.168.1.10

# Create a mount point and mount the share
mkdir -p /mnt/nfsshare
mount -t nfs 192.168.1.10:/srv/share /mnt/nfsshare

# Test read/write access
echo "NFS test" > /mnt/nfsshare/test.txt
cat /mnt/nfsshare/test.txt

Step 6 — Make the Mount Persistent via /etc/fstab

Add an /etc/fstab entry on the client so the NFS share mounts automatically at boot. The _netdev option tells systemd to wait for network availability before attempting the mount, preventing boot failures on systems that initialize NFS before the network is fully up.

# Add to /etc/fstab on the CLIENT
echo '192.168.1.10:/srv/share  /mnt/nfsshare  nfs  defaults,_netdev,rw,sync  0 0' >> /etc/fstab

# Test that the fstab entry is valid
umount /mnt/nfsshare
mount -a
df -h /mnt/nfsshare

Conclusion

You have successfully set up NFS file sharing on RHEL 8, covering server installation, export configuration, firewalld rules, and client mounting both manually and persistently through /etc/fstab. NFS is a powerful, low-overhead way to share files across a Linux network and integrates naturally with the RHEL ecosystem. For production deployments, consider Kerberos-based NFS security (sec=krb5), NFSv4 ACLs, and autofs for on-demand mounting of home directories or project shares.

Next steps: How to Configure Samba File Sharing on RHEL 8, How to Configure LVM on RHEL 8, and How to Automate Backups with rsync and cron on RHEL 8.