Network File Services  «Prev  Next»

Lesson 4Configuring an NFS server
ObjectiveConfigure an NFS server.

Configuring an NFS Server

By default, Red Hat Linux supports NFS:
  1. Red Hat supplies precompiled NFS modules for the Linux kernel, which the kernel loads when you mount a NFS filesystem.
  2. Red Hat Linux starts portmap automatically at boot.
  3. 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.

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
  1. 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.
  2. The first field specifies the filesystem to export. In this case, NFS exports all files in the server's /projects filesystem.
  3. 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
  4. The first field specifies the filesystem to export. In this case, NFS exports all files in the server's /schedules filesystem.
  5. 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.
  6. The first field specifies the filesystem to export. in this case, NFS exports all files in the server's /user filesystem.
  7. 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

etc/exports file

Working with exported filesystems

The exportfs command is the general tool for working with exported filesystems. You will most often use exportfs in one of four ways:
  1. To notify the NFS system you made changes to /etc/exports. Once you have changed your exported filesystems, run exportfs -r to incorporate them.
  2. 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.
  3. To export all filesystems, which you might need after you've unexported them all. Use exportfs -a to export all filesystems.
  4. 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