Network File System (NFS) allows you to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems as if they were local files.
This guide explains how to set up NFS Server in CentOS Stream 9.
The setup is based on the following network environment:
dlp.emc.world (IP: 10.0.0.30)node01.emc.world (IP: 10.0.0.51)Install NFS Utilities
[root@dlp ~]# dnf -y install nfs-utils
Configure NFS
Edit /etc/idmapd.conf to set your domain:
# /etc/idmapd.conf
Domain = emc.world
Define the share in /etc/exports:
# /etc/exports
/home/nfsshare 10.0.0.0/24(rw,no_root_squash)
Create the NFS share directory:
[root@dlp ~]# mkdir /home/nfsshare
Enable and start NFS services:
[root@dlp ~]# systemctl enable --now rpcbind nfs-server
Configure Firewall for NFS
If Firewalld is active, allow NFS service:
[root@dlp ~]# firewall-cmd --add-service=nfs
[root@dlp ~]# firewall-cmd --add-service={nfs3,mountd,rpc-bind}
[root@dlp ~]# firewall-cmd --runtime-to-permanent
rw: Read/Write access.ro: Read-only access.sync: Synchronize changes.async: Asynchronous operations.secure: Use secure ports.insecure: Allow all ports.root_squash: Map root user access to anonymous user.no_root_squash: Do not map root user access.all_squash: Map all users to anonymous user.no_all_squash: Do not map users to anonymous user.anonuid & anongid: Set UID/GID for anonymous user.