/etc/exports file
The /etc/exports file indicates all directories that a server exports to its clients.
Each line in the file specifies a single directory. A directory can be specified twice in the /etc/exports file: once for NFS version 2 or NFS version 3, and once for NFS version 4. The server automatically exports the listed directories each time the NFS server is started. These exported directories can then be mounted by clients. The syntax of a line in the /etc/exports file is:
directory -option[,option]
The directory is the full path name of the directory. Options can designate a simple flag such as ro or a list of host names. The /etc/rc.nfs script does not start the nfsd daemons or the rpc.mountd daemon if the /etc/exports file does not exist.
The following example illustrates entries from an /etc/exports file:
/usr/games -ro,access=ballet:jazz:tap
/home -root=ballet,access=ballet
/var/tmp
/usr/lib -access=clients
/accounts/database -vers=4,sec=krb5,access=accmachines,root=accmachine1
/tmp -vers=3,ro
/tmp -vers=4,sec=krb5,access=accmachines,root=accmachine1
The first entry in this example specifies that the /usr/games
directory
can be mounted by the systems named ballet
, jazz
,
and tap
. These systems can read data and run programs from
the directory, but they cannot write in the directory.
The second entry in this example specifies that the /home
directory
can be mounted by the system ballet
and that root access
is allowed for the directory.
The third entry in this example specifies that any client can mount the /var/tmp
directory.
(Notice the absence of an access list.)
The fourth entry in this example specifies an access list designated by the netgroup
clients
. In other words, these machines designated as belonging to the netgroup
clients
can mount the /usr/lib
directory from this server. (A
netgroup is a network-wide group allowed access to certain network resources for security or
organizational purposes. Netgroups are controlled by using NIS.
The fifth entry allows access to the directory /accounts/database only
to clients in the accmachines
netgroup using NFS version
4 protocol and accessing the directory using Kerberos 5 authentication. Root
access is allowed only from accmachine1
.
The sixth and the seventh entries export the /tmp
directory using different
versions and options. If two entries for the same directory with different NFS versions exist in the
/etc/exports file, the exportfs command will export both. If a directory has the
same options for NFS version 4 and NFS version 3, you can have one entry in the
/etc/exports file specifying -vers=3:4
.