Red Hat supplies precompiled NFS modules for the Linux kernel, which the kernel loads when you mount a NFS filesystem.
Red Hat Linux starts portmap automatically at boot.
If you configure your network information, then Red Hat Linux automatically starts the NFS server daemons rpc.mountd and rpc.nfsd at boot.
Because Red Hat Linux starts the necessary servers, you only need to configure the exported filesystems. The /etc/exports file describes exported filesystems, including access permissions and read/write privileges. To configure the exported filesystems, open /etc/exports in your favorite editor.
Steps to configure Red Hat NFS Server
To configure a Red Hat NFS server, you can follow these general steps:
Install the NFS server packages using the package manager of your choice. You may need to install multiple packages depending on your specific needs.
Configure the NFS server by editing the "/etc/exports" file. This file specifies the directories and files that will be exported by the NFS server, as well as the access permissions and options for each exported item.
Start the NFS server service using the following command:
systemctl start nfs-server
You can also enable the service to start automatically at boot time using the following command:
systemctl enable nfs-server
Configure the firewall to allow NFS traffic. You may need to add firewall rules to allow NFS traffic through the firewall, depending on your specific firewall configuration.
Test the NFS server by mounting the exported filesystems on a client machine. You can use the "showmount" command to display the list of exported filesystems, and the "mount" command to mount the filesystems on a client machine.
Configure additional NFS server options as needed. You may need to configure other NFS server options such as security settings, performance tuning parameters, and logging settings to meet your specific needs.
These are the general steps to configure a Red Hat NFS server. The exact steps may vary depending on your specific version of Red Hat Linux and your specific configuration needs. It's important to consult the NFS documentation and seek assistance from qualified support resources as needed to ensure that your NFS server is configured correctly and securely.
The /etc/exports file
Regardless of how you edit /etc/exports, you should be familiar with its layout.
One day, you might want to look through the file to make sure it's exporting only those filesystems you want publicly available.
The following MouseOver illustrates the general format of /etc/exports.
Export packages in Red hat
Comments start with a hash (#) mark and instruct NFS to ignore all text to the end of the line. The comment indicates that you are working with the /etc/exports file on the server compute.
The first field specifies the filesystem to export. In this case, NFS exports all files in the server's /projects filesystem.
The second field lists the authorized hosts and access methods for the filesystem in the first field. In this case, all hosts whose name starts with dev will gain read/write access. Hosts named dev1, developer, devnull, and devil will all match this specification and gain read/write access to /projects
The first field specifies the filesystem to export. In this case, NFS exports all files in the server's /schedules filesystem.
The second field lists the authorized hosts and access methods for the filesystem in the first field. In this case, two host match. First, any host named manager will gain read/write access to /schedules. Second, all hosts whose name starts with the dev will gain read only access host named dev1, developer dev null and devil will all match this the specification and gain read only access to schedule.
The first field specifies the filesystem to export. in this case, NFS exports all files in the server's /user filesystem.
The second field lists the authorized hosts and access methods for the filesystem in the first field.
In this case no explicit host name is given. The NFS system interprets this as meaning all hosts so every host on the network gains readonly access to /user
The exportfs command is the general tool for working with exported filesystems. You will most often use exportfs in one of four ways:
To notify the NFS system you made changes to /etc/exports. Once you have changed your exported filesystems, run exportfs -r to incorporate them.
To unexport (disconnect an exported filesystem) all filesystems listed in /etc/exports. You might want to unexport the filesystems if you discover a security breach or are running diagnostics. To do so, run exportfs -ua.
To export all filesystems, which you might need after you've unexported them all. Use exportfs -a to export all filesystems.
To show all exported filesystems. Use exportfs -v to list filesystems that are currently exported.
Unexport: The opposite of exporting. A jargon term meaning to make a previously exported NFS filesystem unavailable.
In the next lesson, you will learn about NFS security issues.
Configuring Nfs Server - Exercise
Before moving on to the next lesson, click the Exercise link below to practice configuring an NFS server. Configuring Nfs Server - Exercise