Книга: Fedora™ Unleashed, 2008 edition

NFS Server Configuration

NFS Server Configuration

You configure the NFS server by editing the /etc/exports file. This file is similar to the /etc/fstab file in that it is used to set the permissions for the file systems being exported. The entries look like this:

/file/system yourhost(options) *.yourdomain.com(options) 192.168.2.0/24(options)

This shows three common clients to which to share /file/system. The first, yourhost, shares /file/system to just one host. The second, .yourdomain.com, uses the asterisk (*) as a wildcard to enable all hosts in yourdomain.com to access /file/system. The third share enables all hosts of the Class C network, 192.168.0.0, to access /file/share. For security, it is best not to use shares like the last two across the Internet because all data will be readable by any network the data passes by. Some common options are shown in Table 19.1.

TABLE 19.1 /etc/fstab Options

Option Purpose
rw Gives read and write access
ro Gives read-only access
async Writes data when the server, not the client, feels the need
sync Writes data as it is received

The following is an example of an /etc/exports file:

# etc/exports file for myhost.mydomain.com
/usr/local   yourhost(ro,show)
/home/ahudson *.yourdomain.com(rw,hide,sync)

This file exports (makes available) /usr/local to yourhost. The mount is read-only (which is good for a directory of binary files that don't get written to). It also allows users on yourhost to see the contents of file systems that might be mounted on /usr/local. The second export mounts /home/ahudson to any host in yourdomain.com. It doesn't allow subsidiary file systems to be viewed, but you can read and write to the file system.

After you have finished with the /etc/exports file, you will check to see whether the NFS service is started by using the command:

service nfs status

If you see a message saying that services are stopped, issue the following command:

service nfs start

and watch as the related NFS services are started. When the services are started, you can enter the command

# /usr/sbin/exportfs -r

to export all the file systems in the /etc/exports file to a list named xtab under the /var/lib/nfs directory, which is used as a guide for mounting when a remote computer asks for a directory to be exported. The -r option to the command reads the entire /etc/exports file and mounts all the entries. The exportfs command can also be used to export specific files temporarily. Here's an example of using exportfs to export a file system:

/usr/sbin/exportfs -o async yourhost:/usr/tmp

This command exports /usr/tmp to yourhost with the async option.

Be sure to restart the NFS server after making any changes to /etc/exports. If you prefer, you can use Fedora's system-config-nfs graphical client to set up NFS while using X. Start the client by going to System, Administration, Server Settings, NFS.

After you press Enter, you are prompted for the root password. Type in the password and click OK, and you see the main window. Click the Add button, and you see the Add NFS Share dialog box, as shown in Figure 19.1.


FIGURE 19.1 Fedora's system-config-nfs client can be used to quickly set up local directories for export via NFS.

In the Directory text box, type a name of a directory to be exported; in the Host(s) text box, type a hostname or the IP address of a remote host that is to be allowed access to the directory. By default, a directory is exported as read-only, but you can choose read and write access by clicking either option in the Basic Permissions area of the dialog box. When finished, click the OK button, click the Apply button, and then use the File menu to quit.

NOTE

As part of your configuration for using NFS, you might need to enable the port on your firewall. Go to System, Administration, Firewall to open the Firewall configuration utility. Check the box next to NFS4 and click Apply to apply the new firewall policy.

Оглавление книги

Оглавление статьи/книги

Генерация: 5.312. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз