NFS Server and Client Setup

Prepared by: Anwer Sadath Abdul Muttaliff

Objective

This project demonstrates how to set up an NFS server on CentOS 9 and configure a client to access shared directories.

Step 1: Install NFS Server

Install NFS Packages
$ sudo yum install -y nfs-utils
Install NFS Server
Enable and Start NFS Services
$ sudo systemctl enable --now nfs-server.service
$ sudo systemctl status nfs-server.service

Step 2: Create and Configure the Shared Directory

Create Shared Directories
$ sudo mkdir -p /exports/backup
$ sudo mkdir -p /exports/documents
Set Permissions
$ sudo chmod 770 /exports/backup
$ sudo chmod 770 /exports/documents
$ sudo chgrp group1 /exports/backup
$ sudo chgrp group1 /exports/documents
$ sudo chmod g+s /exports/backup
$ sudo chmod g+s /exports/documents
Set Permissions

Step 3: Configure NFS Exports

Edit the Exports File
$ sudo vim /etc/exports

Add the following lines:

/exports/documents  192.168.1.88(rw,sync,no_root_squash)
/exports/backup     192.168.1.88(rw,sync,no_root_squash)

Apply the changes:

$ sudo exportfs -arv
Export NFS Shares

Step 4: Configure Firewall for NFS

Allow NFS Through Firewall
$ sudo firewall-cmd --permanent --add-service=nfs
$ sudo firewall-cmd --permanent --add-service=mountd
$ sudo firewall-cmd --permanent --add-service=rpc-bind
$ sudo firewall-cmd --reload
Firewall Configuration

Step 5: Configure NFS Client

Install NFS Utilities
$ sudo yum install nfs-utils
Verify Connectivity
$ ping 192.168.1.87
Ping NFS Server
Mount NFS Shares
$ mkdir -p /tmp/backup
$ mkdir -p /tmp/documents
$ mount -t nfs 192.168.1.87:/exports/backup /tmp/backup/
$ mount -t nfs 192.168.1.87:/exports/documents /tmp/documents/
Verify NFS Mount
Back to Top Back to Home