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