]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/exportfs/exports.man
7a032bc9609453e3295e84b891c742dc2cfe84a5
[nfs-utils.git] / utils / exportfs / exports.man
1 .TH EXPORTS 5 "28 October 1999"
2 .UC 5
3 .SH NAME
4 exports \- NFS file systems being exported (for Kernel based NFS)
5 .SH SYNOPSIS
6 .B /etc/exports
7 .SH DESCRIPTION
8 The file
9 .I /etc/exports
10 serves as the access control list for file systems which may be
11 exported to NFS clients.  It is used by
12 .IR exportfs (8)
13 to give information to
14 .IR mountd (8)
15 and to the kernel based NFS file server daemon
16 .IR nfsd (8).
17 .PP
18 The file format is similar to the SunOS
19 .I exports
20 file. Each line contains an export point and a whitespace-separated list
21 of clients allowed to mount the file system at that point. Each listed
22 client may be immediately followed by a parenthesized, comma-separated
23 list of export options for that client. No whitespace is permitted
24 between a client and its option list.
25 .PP
26 Blank lines are ignored.  A pound sign ("#") introduces a comment to the
27 end of the line. Entries may be continued across newlines using a
28 backslash. If an export name contains spaces it should be quoted using
29 double quotes. You can also specify spaces or other unusual character in
30 the export name using a backslash followed by the character code as three
31 octal digits.
32 .PP
33 .SS Machine Name Formats
34 NFS clients may be specified in a number of ways:
35 .IP "single host
36 This is the most common format. You may specify a host either by an
37 abbreviated name recognized be the resolver, the fully qualified domain
38 name, or an IP address.
39 .IP "netgroups
40 NIS netgroups may be given as
41 .IR @group .
42 Only the host part of each
43 netgroup members is consider in checking for membership.  Empty host
44 parts or those containing a single dash (\-) are ignored.
45 .IP "wildcards
46 Machine names may contain the wildcard characters \fI*\fR and \fI?\fR.
47 This can be used to make the \fIexports\fR file more compact; for instance,
48 \fI*.cs.foo.edu\fR matches all hosts in the domain
49 \fIcs.foo.edu\fR.  As these characters also match the dots in a domain
50 name, the given pattern will also match all hosts within any subdomain
51 of \fIcs.foo.edu\fR.
52 .IP "IP networks
53 You can also export directories to all hosts on an IP (sub-) network
54 simultaneously. This is done by specifying an IP address and netmask pair
55 as
56 .IR address/netmask
57 where the netmask can be specified in dotted-decimal format, or as a
58 contiguous mask length (for example, either `/255.255.252.0' or `/22' appended
59 to the network base address result in identical subnetworks with 10 bits of
60 host). Wildcard characters generally do not work on IP addresses, though they
61 may work by accident when reverse DNS lookups fail.
62 '''.TP
63 '''.B =public
64 '''This is a special ``hostname'' that identifies the given directory name
65 '''as the public root directory (see the section on WebNFS in
66 '''.BR nfsd (8)
67 '''for a discussion of WebNFS and the public root handle). When using this
68 '''convention,
69 '''.B =public
70 '''must be the only entry on this line, and must have no export options
71 '''associated with it. Note that this does
72 '''.I not
73 '''actually export the named directory; you still have to set the exports
74 '''options in a separate entry.
75 '''.PP
76 '''The public root path can also be specified by invoking
77 '''.I nfsd
78 '''with the
79 '''.B \-\-public\-root
80 '''option. Multiple specifications of a public root will be ignored.
81 .PP
82 .SS RPCSEC_GSS security
83 To restrict access to an export using rpcsec_gss security, use the special
84 string "gss/krb5" as the client.  It is not possible to simultaneously require
85 rpcsec_gss and to make requirements on the IP address of the client.
86 .PP
87 .SS General Options
88 .IR exportfs
89 understands the following export options:
90 .TP
91 .IR secure "\*d
92 This option requires that requests originate on an internet port less
93 than IPPORT_RESERVED (1024). This option is on by default. To turn it
94 off, specify
95 .IR insecure .
96 .TP
97 .IR rw
98 Allow both read and write requests on this NFS volume. The
99 default is to disallow any request which changes the filesystem.
100 This can also be made explicit by using
101 the
102 .IR ro " option.
103 .TP
104 .IR async
105 This option allows the NFS server to violate the NFS protocol and
106 reply to requests before any changes made by that request have been
107 committed to stable storage (e.g. disc drive).
108
109 Using this option usually improves performance, but at the cost that
110 an unclean server restart (i.e. a crash) can cause data to be lost or
111 corrupted.
112
113 In releases of nfs-utils upto and including 1.0.0, this option was the
114 default.  In this and future releases,
115 .I sync
116 is the default, and
117 .I async
118 must be explicit requested if needed.
119 To help make system adminstrators aware of this change, 'exportfs'
120 will issue a warning if neither
121 .I sync
122 nor
123 .I async
124 is specified.
125 .TP
126 .IR no_wdelay
127 This option has no effect if
128 .I async
129 is also set.  The NFS server will normally delay committing a write request
130 to disc slightly if it suspects that another related write request may be in
131 progress or may arrive soon.  This allows multiple write requests to
132 be committed to disc with the one operation which can improve
133 performance.  If an NFS server received mainly small unrelated
134 requests, this behaviour could actually reduce performance, so
135 .IR no_wdelay
136 is available to turn it off.
137 The default can be explicitly requested with the
138 .IR wdelay " option.
139 .TP
140 .IR nohide
141 This option is based on the option of the same name provided in IRIX
142 NFS.  Normally, if a server exports two filesystems one of which is
143 mounted on the other, then the client will have to mount both
144 filesystems explicitly to get access to them.  If it just mounts the
145 parent, it will see an empty directory at the place where the other
146 filesystem is mounted.  That filesystem is "hidden".
147
148 Setting the
149 .I nohide
150 option on a filesystem causes it not to be hidden, and an
151 appropriately authorised client will be able to move from the parent to
152 that filesystem without noticing the change.
153
154 However, some NFS clients do not cope well with this situation as, for
155 instance, it is then possible for two files in the one apparent
156 filesystem to have the same inode number.
157
158 The
159 .I nohide
160 option is currently only effective on
161 .I "single host
162 exports.  It does not work reliably with netgroup, subnet, or wildcard
163 exports. 
164
165 This option can be very useful in some situations, but it should be
166 used with due care, and only after confirming that the client system
167 copes with the situation effectively.
168
169 The option can be explicitly disabled with
170 .IR hide .
171 .TP
172 .IR no_subtree_check
173 This option disables subtree checking, which has mild security
174 implications, but can improve reliability is some circumstances.
175
176 If a subdirectory of a filesystem is exported, but the whole
177 filesystem isn't then whenever a NFS request arrives, the server must
178 check not only that the accessed file is in the appropriate filesystem
179 (which is easy) but also that it is in the exported tree (which is
180 harder). This check is called the
181 .IR subtree_check .
182
183 In order to perform this check, the server must include some
184 information about the location of the file in the "filehandle" that is
185 given to the client.  This can cause problems with accessing files that
186 are renamed while a client has them open (though in many simple cases
187 it will still work).
188
189 subtree checking is also used to make sure that files inside
190 directories to which only root has access can only be accessed if the
191 filesystem is exported with
192 .I no_root_squash
193 (see below), even the file itself allows more general access.
194
195 As a general guide, a home directory filesystem, which is normally
196 exported at the root and may see lots of file renames, should be
197 exported with subtree checking disabled.  A filesystem which is mostly
198 readonly, and at least doesn't see many file renames (e.g. /usr or
199 /var) and for which subdirectories may be exported, should probably be
200 exported with subtree checks enabled.
201
202 The default of having subtree checks enabled, can be explicitly
203 requested with
204 .IR subtree_check .
205
206 .TP
207 .IR insecure_locks
208 .TP
209 .IR no_auth_nlm
210 This option (the two names are synonymous) tells the NFS server not to require authentication of
211 locking requests (i.e. requests which use the NLM protocol).  Normally
212 the NFS server will require a lock request to hold a credential for a
213 user who has read access to the file.  With this flag no access checks
214 will be performed.
215
216 Early NFS client implementations did not send credentials with lock
217 requests, and many current NFS clients still exist which are based on
218 the old implementations.  Use this flag if you find that you can only
219 lock files which are world readable.
220
221 The default behaviour of requiring authentication for NLM requests can
222 be explicitly requested with either of the synonymous
223 .IR auth_nlm ,
224 or
225 .IR secure_locks .
226
227 '''.TP
228 '''.I noaccess
229 '''This makes everything below the directory inaccessible for the named
230 '''client.  This is useful when you want to export a directory hierarchy to
231 '''a client, but exclude certain subdirectories. The client's view of a
232 '''directory flagged with noaccess is very limited; it is allowed to read
233 '''its attributes, and lookup `.' and `..'. These are also the only entries
234 '''returned by a readdir.
235 '''.TP
236 '''.IR link_relative
237 '''Convert absolute symbolic links (where the link contents start with a
238 '''slash) into relative links by prepending the necessary number of ../'s
239 '''to get from the directory containing the link to the root on the
240 '''server.  This has subtle, perhaps questionable, semantics when the file
241 '''hierarchy is not mounted at its root.
242 '''.TP
243 '''.IR link_absolute
244 '''Leave all symbolic link as they are. This is the default operation.
245
246 .TP
247 .IR mountpoint= path
248 .TP
249 .I mp
250 This option makes it possible to only export a directory if it has
251 successfully been mounted.
252 If no path is given (e.g.
253 .IR mountpoint " or " mp )
254 then the export point must also be a mount point.  If it isn't then
255 the export point is not exported.  This allows you to be sure that the
256 directory underneath a mountpoint will never be exported by accident
257 if, for example, the filesystem failed to mount due to a disc error.
258
259 If a path is given (e.g.
260 .IR mountpoint= "/path or " mp= /path)
261 then the nominted path must be a mountpoint for the exportpoint to be
262 exported.
263
264 .TP
265 .IR fsid= num
266 This option forces the filesystem identification portion of the file
267 handle and file attributes used on the wire to be
268 .I num
269 instead of a number derived from the major and minor number of the
270 block device on which the filesystem is mounted.  Any 32 bit number
271 can be used, but it must be unique amongst all the exported filesystems.
272
273 This can be useful for NFS failover, to ensure that both servers of
274 the failover pair use the same NFS file handles for the shared filesystem
275 thus avoiding stale file handles after failover.
276
277 Some Linux filesystems are not mounted on a block device; exporting
278 these via NFS requires the use of the
279 .I fsid
280 option (although that may still not be enough).
281
282 The value  0 has a special meaning when use with NFSv4.  NFSv4 has a
283 concept of a root of the overall exported filesystem. The export point
284 exported with fsid=0 will be used as this root.
285
286 .SS User ID Mapping
287 .PP
288 .I nfsd
289 bases its access control to files on the server machine on the uid and
290 gid provided in each NFS RPC request. The normal behavior a user would
291 expect is that she can access her files on the server just as she would
292 on a normal file system. This requires that the same uids and gids are
293 used on the client and the server machine. This is not always true, nor
294 is it always desirable.
295 .PP
296 Very often, it is not desirable that the root user on a client machine
297 is also treated as root when accessing files on the NFS server. To this
298 end, uid 0 is normally mapped to a different id: the so-called
299 anonymous or
300 .I nobody
301 uid. This mode of operation (called `root squashing') is the default,
302 and can be turned off with
303 .IR no_root_squash .
304 .PP
305 By default,
306 '''.I nfsd
307 '''tries to obtain the anonymous uid and gid by looking up user
308 '''.I nobody
309 '''in the password file at startup time. If it isn't found, a uid and gid
310 .I exportfs
311 chooses a uid and gid
312 of -2 (i.e. 65534) for squashed access. These values can also be overridden by
313 the
314 .IR anonuid " and " anongid
315 options.
316 '''.PP
317 '''In addition to this, 
318 '''.I nfsd
319 '''lets you specify arbitrary uids and gids that should be mapped to user
320 '''nobody as well.
321 Finally, you can map all user requests to the
322 anonymous uid by specifying the
323 .IR all_squash " option.
324 '''.PP 
325 '''For the benefit of installations where uids differ between different
326 '''machines, 
327 '''.I nfsd
328 '''provides several mechanism to dynamically map server uids to client
329 '''uids and vice versa: static mapping files, NIS-based mapping, and
330 '''.IR ugidd -based
331 '''mapping.
332 '''.PP
333 '''.IR ugidd -based
334 '''mapping is enabled with the 
335 '''.I map_daemon
336 '''option, and uses the UGID RPC protocol. For this to work, you have to run
337 '''the
338 '''.IR ugidd (8)
339 '''mapping daemon on the client host. It is the least secure of the three methods,
340 '''because by running
341 '''.IR ugidd ,
342 '''everybody can query the client host for a list of valid user names. You
343 '''can protect yourself by restricting access to
344 '''.I ugidd
345 '''to valid hosts only. This can be done by entering the list of valid
346 '''hosts into the
347 '''.I hosts.allow
348 '''or 
349 '''.I hosts.deny
350 '''file. The service name is
351 '''.IR ugidd .
352 '''For a description of the file's syntax, please read
353 '''.IR hosts_access (5).
354 '''.PP
355 '''Static mapping is enabled by using the
356 '''.I map_static
357 '''option, which takes a file name as an argument that describes the mapping.
358 '''NIS-based mapping queries the client's NIS server to obtain a mapping from
359 '''user and group names on the server host to user and group names on the
360 '''client.
361 .PP
362 Here's the complete list of mapping options:
363 .TP
364 .IR root_squash
365 Map requests from uid/gid 0 to the anonymous uid/gid. Note that this does
366 not apply to any other uids that might be equally sensitive, such as user
367 .IR bin .
368 .TP
369 .IR no_root_squash
370 Turn off root squashing. This option is mainly useful for diskless clients.
371 '''.TP
372 '''.IR squash_uids " and " squash_gids
373 '''This option specifies a list of uids or gids that should be subject to
374 '''anonymous mapping. A valid list of ids looks like this:
375 '''.IP
376 '''.IR squash_uids=0-15,20,25-50
377 '''.IP
378 '''Usually, your squash lists will look a lot simpler.
379 .TP
380 .IR all_squash
381 Map all uids and gids to the anonymous user. Useful for NFS-exported
382 public FTP directories, news spool directories, etc. The opposite option
383 is 
384 .IR no_all_squash ,
385 which is the default setting.
386 '''.TP
387 '''.IR map_daemon
388 '''This option turns on dynamic uid/gid mapping. Each uid in an NFS request
389 '''will be translated to the equivalent server uid, and each uid in an
390 '''NFS reply will be mapped the other way round. This option requires that
391 '''.IR rpc.ugidd (8)
392 '''runs on the client host. The default setting is
393 '''.IR map_identity ,
394 '''which leaves all uids untouched. The normal squash options apply regardless
395 '''of whether dynamic mapping is requested or not.
396 '''.TP
397 '''.IR map_static
398 '''This option enables static mapping. It specifies the name of the file
399 '''that describes the uid/gid mapping, e.g.
400 '''.IP
401 '''.IR map_static=/etc/nfs/foobar.map
402 '''.IP
403 '''The file's format looks like this
404 '''.IP
405 '''.nf
406 '''.ta +3i
407 '''# Mapping for client foobar:
408 '''#    remote     local
409 '''uid  0-99       -       # squash these
410 '''uid  100-500    1000    # map 100-500 to 1000-1400
411 '''gid  0-49       -       # squash these
412 '''gid  50-100     700     # map 50-100 to 700-750
413 '''.fi
414 '''.TP
415 '''.IR map_nis
416 '''This option enables NIS-based uid/gid mapping. For instance, when
417 '''the server encounters the uid 123 on the server, it will obtain the
418 '''login name associated with it, and contact the NFS client's NIS server
419 '''to obtain the uid the client associates with the name.
420 '''.IP
421 '''In order to do this, the NFS server must know the client's NIS domain.
422 '''This is specified as an argument to the
423 '''.I map_nis
424 '''options, e.g.
425 '''.IP
426 '''.I map_nis=foo.com
427 '''.IP
428 '''Note that it may not be sufficient to simply specify the NIS domain
429 '''here; you may have to take additional actions before
430 '''.I nfsd
431 '''is actually able to contact the server. If your distribution uses
432 '''the NYS library, you can specify one or more NIS servers for the
433 '''client's domain in
434 '''.IR /etc/yp.conf .
435 '''If you are using a different NIS library, you may have to obtain a
436 '''special
437 '''.IR ypbind (8)
438 '''daemon that can be configured via
439 '''.IR yp.conf .
440 .TP
441 .IR anonuid " and " anongid
442 These options explicitly set the uid and gid of the anonymous account.
443 This option is primarily useful for PC/NFS clients, where you might want
444 all requests appear to be from one user. As an example, consider the
445 export entry for
446 .B /home/joe
447 in the example section below, which maps all requests to uid 150 (which
448 is supposedly that of user joe).
449 .IP
450 .SH EXAMPLE
451 .PP
452 .nf
453 .ta +3i
454 # sample /etc/exports file
455 /               master(rw) trusty(rw,no_root_squash)
456 /projects       proj*.local.domain(rw)
457 /usr            *.local.domain(ro) @trusted(rw)
458 /home/joe       pc001(rw,all_squash,anonuid=150,anongid=100)
459 /pub            (ro,insecure,all_squash)
460 '''/pub/private    (noaccess)
461 .fi
462 .PP
463 The first line exports the entire filesystem to machines master and trusty.
464 In addition to write access, all uid squashing is turned off for host
465 trusty. The second and third entry show examples for wildcard hostnames
466 and netgroups (this is the entry `@trusted'). The fourth line shows the
467 entry for the PC/NFS client discussed above. Line 5 exports the
468 public FTP directory to every host in the world, executing all requests
469 under the nobody account. The
470 .I insecure 
471 option in this entry also allows clients with NFS implementations that
472 don't use a reserved port for NFS.
473 ''' The last line denies all NFS clients
474 '''access to the private directory.
475 '''.SH CAVEATS
476 '''Unlike other NFS server implementations, this
477 '''.I nfsd
478 '''allows you to export both a directory and a subdirectory thereof to
479 '''the same host, for instance 
480 '''.IR /usr " and " /usr/X11R6 .
481 '''In this case, the mount options of the most specific entry apply. For
482 '''instance, when a user on the client host accesses a file in 
483 '''.IR /usr/X11R6 ,
484 '''the mount options given in the 
485 '''.I /usr/X11R6 
486 '''entry apply. This is also true when the latter is a wildcard or netgroup
487 '''entry.
488 .SH FILES
489 /etc/exports
490 '''.SH DIAGNOSTICS
491 '''An error parsing the file is reported using syslogd(8) as level NOTICE from
492 '''a DAEMON whenever nfsd(8) or mountd(8) is started up.  Any unknown
493 '''host is reported at that time, but often not all hosts are not yet known
494 '''to named(8) at boot time, thus as hosts are found they are reported
495 '''with the same syslogd(8) parameters.