Red hat linux

Setting Up an NFS Server and Client on CentOS 7

I’m using two CentOS systems here:

NFS Server: server.example.com, IP address: 192.168.1.100
NFS Client: client.example.com, IP address: 192.168.1.101

Configure the Firewall

firewall-cmd --permanent --zone=public --add-service=nfs
firewall-cmd --reload

Installing NFS and enable and start the nfs server service.(Client / Server)

yum -y install nfs-utils
systemctl enable nfs-server.service
systemctl start nfs-server.service

Exporting Directories on the Server

mkdir /var/nfs
chown nfsnobody:nfsnobody /var/nfs
chmod 755 /var/nfs

Now we must modify /etc/exports where we “export” our NFS shares.

#vim /etc/exports
/home           192.168.1.101(rw,sync,no_root_squash,no_subtree_check)
/var/nfs        192.168.1.101(rw,sync,no_subtree_check)

#exportfs -a

Mounting the NFS Shares on the Client
client:
First we create the directories where we want to mount the NFS shares

mkdir -p /mnt/nfs/home
mkdir -p /mnt/nfs/var/nfs

Afterwards, we can mount them as follows:

mount 192.168.1.100:/home /mnt/nfs/home
mount 192.168.1.100:/var/nfs /mnt/nfs/var/nfs

Open /etc/fstab and append the following lines:

192.168.1.100:/home  /mnt/nfs/home   nfs      rw,sync,hard,intr  0     0
192.168.1.100:/var/nfs  /mnt/nfs/var/nfs   nfs      rw,sync,hard,intr  0     0

Leave a Reply

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