Short for Network File Share, NFS is a cross-platform client/server protocol that allows client computers to access files shared by an NFS server over a network. Client systems can mount file systems locally from an NFS server and access files and folders as if they were mounted locally. In this guide we will guide you through the installation and configuration of the NFS server on CentOS 8 / RHEL 8.

Pay attention: NFSv3 and v4 are supported in CentOS 8 or RHEL 8. NFSv3 provides secure asynchronous recording and supports 64-bit size and offset files. Although NFSv4 goes through an operating system firewall and supports ACL (Access Control List) and does not require rpcbind maintenance.

NFS Server/ClientConfiguration

Before we start, we will use the following parameters to simulate NFS operation under client/server conditions

  • IP server machines : Address :   192,168,2,102 CentOS 8
  • IP of the client computer : Address :   192,168,2,103 CentOS 8

Let’s start our installation and start installing the NFS on the server machine.

Step 1) Install and configure NFS on a CentOS 8 / RHEL 8 server

First, we will install an NFS server package called nfs-utils that will act as an NFS daemon. To install the nfs-utils package, start the terminal and execute the command:

$ ship dnf installation nfs-utils -y

In the example below, nfs-utils have already been installed.

How to set up an NFS server for CentOS 8 / RHEL 8

Once the installation is complete, start and activate the nfs-server service, so that it will automatically restart when you restart. Execute the following commands,

$ sudo systemctl start nfs-server.service
$ sudo systemctl start nfs-server.service

How to set up an NFS server for CentOS 8 / RHEL 8

To confirm that the NFS service is working, run it:

$ stands sudo systemctl nfs-server.service

How to set up an NFS server for CentOS 8 / RHEL 8

You can check which version of the nfs log you are using by executing the command:

$ rpcinfo -p | grep nfs

The version is indicated by the second column in the result below.

How to set up an NFS server for CentOS 8 / RHEL 8

For additional configuration of the NFS server, you can find the configuration files in /etc/nfs.conf, the NFS demo configuration file, and in /etc/nfsmount.conf, the NFS mount configuration file.

Step 2) Creation and export of SNFshare

In this phase we create a file system that is shared with the server on the client systems. In this manual we create a directory in /mnt/nfs_share/docs as shown below

$ ship mkdir -p /mnt/nfs_share/docs

How to set up an NFS server for CentOS 8 / RHEL 8

To avoid file restrictions for a shared NFS folder, it is recommended to set the folder property as shown in the image. This allows you to create files from client systems without any problems.

$ Ship Chow – person: /mnt/nfs_share/ocs

You can also choose to customize the access rights to the folder according to your preferences. For example, in this manual we will assign all rights (read, write and execute) to the NFS share folder.

$ ship chmod -R 777 /mnt/nfs_s_share/docs

How to set up an NFS server for CentOS 8 / RHEL 8

In order for the changes to take effect, the NFS daemon must be restarted:

$ sudo systemctl reboot nfs-utils.service

To export an NFS share so that client systems can access it, we need to edit the /etc/export file. You can allow multiple clients to access the resource by specifying a subnetwork, as shown in the following figure

/mnt/nfs_shares/docs 192.168.2.0/24(rw,sync,no_all_squash,root_squash)

You can also specify each customer on a separate line:

/mnt/nfs_shares/docs client IP(rw,sync,no_all_squash,root_squash)

/mnt/nfs_shares/docs client IP(rw,sync,no_all_squash,root_squash)

With our installation we provide access to our client computer with the IP address 192.168.2.103. Add the following line to /etc/export:

$ ship vi /etc/exports
/mnt/nfs_shares/docs 192.168.2.103(rw,sync,no_all_squash,root_squash)

Save the file and close it. Use the Cats command to confirm the entry, as shown in the figure.

[[Email protection]] cat /etc/exports/mnt/nfs_shares/docs 192.168.2.103(rw,sync,no_all_squash,root_squash [[Email protection]]] cat /etc/exports/mnt/nfs_shares/docs 192.168.2.103(rw,sync,no_all_squash,root_squash).

Let’s look at the value of the parameters used:

  • rw – It means read/write. It grants reading and writing rights for the SNF.
  • Synchronization – this setting requires changes to be written to disc before any other operation can be performed.
  • no_all_squash – Displays all client request UIDs and GIDs for identical UIDs and GIDs located on the NFS server.
  • root_squash – this attribute shows requests from a client-side root user to an anonymous UID / GID

To export the folder created above, use the export command as shown in the figure :

Sudo Export -arv

How to set up an NFS server for CentOS 8 / RHEL 8

The -a option means that all folders are exported, -r means that all folders are re-exported, and finally the -v flag shows the detailed output.

To be absolutely sure of the export list, you can display the export list with the command

$ sudo export -s

How to set up an NFS server for CentOS 8 / RHEL 8

Perfect! Our export list exists. So far, so good. The only configuration left on the NFS server is to allow NFS services on the firewall.

Step 3) Configuring firewall rules for NFSServers

The last step of the server configuration is to allow NFS services through the firewall on the CentOS 8 server machine. These services are: nfs, rpc-bind and mountd. Therefore, execute the following commands.

sudo firewall-cmd –permanent –add-service=nfs
$ sudo firewall-cmd –permanent –add-service=rpc-bind
$ sudo firewall-cmd –permanent –add-service=mountd

Then restart the firewall to allow the changes to take effect.

$ ship firewall-cmd – reboot

How to set up an NFS server for CentOS 8 / RHEL 8

Now let’s go to the client system and configure it for access to shared NFS resources.

NFSConfiguration of the client system

To configure the client system to access NFS components

Step 1) Install the required SNF packets.

Install on the CentOS 8 client system the necessary packages to access the NFS share located on the NFS server.

$ ship dnf installation nfs-utils nfs4-acl-tools -y

For Debian or Ubuntu systems:

$ install sudo apt nfs-common nfs4-acl-tools -y

How to set up an NFS server for CentOS 8 / RHEL 8

To view the NFS shares on the server, use the showmount command:

Show Mont – 192.168.2.102

How to set up an NFS server for CentOS 8 / RHEL 8

Step 2) Install Remote NFS Share on Server

Next, we need to mount the directory of the external NFS share on the local client system. But let’s start by creating a directory to link the NFS share.

$ sudo mkdir $ sudo mkdir p /mnt/client_share

To mount an NFS share, follow the command below Remember that 192.168.2.102 is the IP address of the NFS server.

$ sudo mount -t nfs 192.168.2.102:/mnt/nfs_shares/docs /mnt/client_share

How to set up an NFS server for CentOS 8 / RHEL 8

You can check whether the NFS part is remotely mounted at runtime :

$ sudo mount | grep -i nfs

How to set up an NFS server for CentOS 8 / RHEL 8

To make the mount resource stable after rebooting, edit the /etc/fstab file and add an entry below.

192.168.2.102:/mnt/nfs_shares/docs /mnt/client_share nfs default 0

How to set up an NFS server for CentOS 8 / RHEL 8

Save the file and close it.

NFS server test and client configuration

At this point we have completed all configurations. However, we have to test our installation and make sure everything works. So first we create a test file in the directory of the shared NFS server and see if it exists in the directory mounted on the NFS client.

$ sudo touch /mnt/nfs_shares/docs/server_nfs_file.txt

How to set up an NFS server for CentOS 8 / RHEL 8

Now go to the client system and check if the file exists on the client side.

ls -l /mnt/client_share/

How to set up an NFS server for CentOS 8 / RHEL 8

Awesome! From the results we can clearly deduce that the file exists. Now we want to do the opposite. We create the file on the NFS client system and check if it is accessible from the NFS server.

Create the file on the client as shown in the figure :

$ sudo touch /mnt/client_share/client_nfs_file.txt

How to set up an NFS server for CentOS 8 / RHEL 8

Now go back to the server and check if the file exists in the directory of your NFS share.

ls -l /mnt/nfs_shares/docs

How to set up an NFS server for CentOS 8 / RHEL 8

Wonderful! We can consult the file and access it.

As you can see, you can easily create files on both the NFS server and the client, and easily share them between the two systems and between other client systems configured to access shared resources. And that brings us to the end of our lesson today. In this tutorial we have shown you how to install and configure the NFS server and client system on CentOS 8 and RHEL 8.centos 8 nfs server,centos nfs server,centos nfs server yum,centos 8 nfs server logs,how to create nfs server in centos,nfs server commands,centos 7 nfs server for vmware,nfs daemon linux

Share: