Configuring an NFS Server
Describes how to configure an NFS server on Oracle Linux.
You configure an NFS server in Oracle Linux 8, Oracle Linux 9, and Oracle Linux 10 by first editing
the /etc/exports file to grant directory access to NFS clients, and then
making those shared directories available using the exportfs command.
Editing the /etc/exports File
The following steps describe how to configure shared directories using the
/etc/exports file.
Configure the directories that an NFS server exports, including which clients can access
those directories and what permissions they have, by editing the
/etc/exports file.
You can also configure exports in files that you create under the
/etc/exports.d directory. For example,
/etc/exports.d/myexports.
The exportfs command
Describes the exportfs command.
The exportfs command lets an administrator export or unexport
directories selectively, without needing to restart the NFS service. When provided with
the appropriate options, the exportfs command writes the exported
directories to the /var/lib/nfs/etab file.
Changes to the list of exported directories are effective immediately because the
nfs-mountd service refers to the etab file for a
specific directory's access privileges.
Using the exportfs Command
If used without any options, the exportfs command displays a list of
exported directories. Providing options to the exportfs command let you be
selective about what gets exported.
The exportfs command options include the following:
-
-r -
Refreshes the list of exported directories in the
/var/lib/nfs/etabfile by incorporating any changes that were made to the list in the/etc/exportsfile. -
-a -
Exports all the directories that are specified in the
/etc/exportsfile. This option can be combined with other options, to specify what action is performed on the directories. -
-u -
Unexports one or more shared directories.
Note
The
exportfs -uacommand suspends NFS file sharing, but keeps all NFS services running. To reenable NFS sharing, use theexportfs -rcommand. -
-v -
Specifies verbose logging, which displays detailed information about the file systems that are being exported or unexported.
Export all directories in the /etc/exports file
To export every directory share defined in the /etc/exports
file:
exportfs -a
Export a single directory from the /etc/exports file
To export only the /var/projects/proj1 directory from the
/etc/exports
file:
exportfs /var/projects/proj1
Unexport a directory defined in the /etc/exports file
To unexport the /var/projects/proj1 directory from the
/etc/exports
file:
exportfs -u /var/projects/proj1
Show detailed information about all exported directories
To show verbose information about all the directories being exported from the
/etc/exports
file:
exportfs -v
For more information on the exportfs command, see the
exportfs(8), exports(5), and
showmount(8) manual pages.
Configuring an NFS Server with TLS
This task shows how to set up the NFS server to use TLS encryption to secure data in transit and enable secure connections from trusted clients.
Ensure that the following are true:
- The system is running Oracle Linux 9 or later.
- You have configured the Oracle Linux system as an NFSv4 server.
- You can use an existing CA certificate or generate a self-signed certificate.
- In production environments, obtain a TLS certificate and private key pair from the Certificate Authority (CA).
- For testing and development only, you can use a self-signed certificate. First, follow the instructions in Generating a Self-Signed Certificate for TLS Authentication and then begin with the step to configure the NFS server for TLS by editing
/etc/tlshd.confthat follows.
- You have installed the
ktls-utilspackage.
This topic applies to Oracle Linux 9 and Oracle Linux 10 only.
The NFS server is now configured to work with TLS connections.
Generating a Self-Signed Certificate for TLS Authentication
For testing and development purposes only, you can use a self-signed certificate to configure NFS with TLS authentication.
This topic applies to Oracle Linux 9 and Oracle Linux 10 only.
This task shows how to generate a self-signed certificate.
Complete these steps on the NFS server.