Network File System (NFS) is a distributed file system protocol which allows a user on a client computer to access files over a computer network much like local storage is accessed.
1. install the package
dnf install nfs-utils -y
2. enable and start the service
systemctl enable nfs-server.service systemctl start nfs-server.service
3. create the share directory and add privileges
mkdir /shared
chown nfsnobody:nfsnobody /shared
chmod 755 /shared
semanage fcontext -a -t public_content_rw_t "/shared(/.*)?"
setsebool -P nfsd_anon_write=1
restorecon -Rv /shared
4. configure the shares
vi /etc/exports
/shared *(ro,async,no_wdelay,no_root_squash)
5. disable NFS v2 and 3
/etc/nfs.conf
[nfsd] vers2=no vers3=no
6. disable listening for the RPCBIND, MOUNT, and NSM protocol calls, which are not necessary in the NFSv4
systemctl mask --now rpc-statd.service rpcbind.service rpcbind.socket
7. export it
exportfs -rav
8. add the firewall rule
firewall-cmd --add-service={nfs,mountd,rpc-bind} firewall-cmd --add-service={nfs,mountd,rpc-bind} --permanent