1exports(5) File Formats Manual exports(5)
2
3
4
6 exports - NFS server export table
7
9 The file /etc/exports contains a table of local physical file systems
10 on an NFS server that are accessible to NFS clients. The contents of
11 the file are maintained by the server's system administrator.
12
13 Each file system in this table has a list of options and an access con‐
14 trol list. The table is used by exportfs(8) to give information to
15 mountd(8).
16
17 The file format is similar to the SunOS exports file. Each line con‐
18 tains an export point and a whitespace-separated list of clients al‐
19 lowed to mount the file system at that point. Each listed client may be
20 immediately followed by a parenthesized, comma-separated list of export
21 options for that client. No whitespace is permitted between a client
22 and its option list.
23
24 Also, each line may have one or more specifications for default options
25 after the path name, in the form of a dash ("-") followed by an option
26 list. The option list is used for all subsequent exports on that line
27 only.
28
29 Blank lines are ignored. A pound sign ("#") introduces a comment to
30 the end of the line. Entries may be continued across newlines using a
31 backslash. If an export name contains spaces it should be quoted using
32 double quotes. You can also specify spaces or other unusual character
33 in the export name using a backslash followed by the character code as
34 three octal digits.
35
36 To apply changes to this file, run exportfs -ra or restart the NFS
37 server.
38
39 Machine Name Formats
40 NFS clients may be specified in a number of ways:
41
42 single host
43 You may specify a host either by an abbreviated name recognized
44 be the resolver, the fully qualified domain name, an IPv4 ad‐
45 dress, or an IPv6 address. IPv6 addresses must not be inside
46 square brackets in /etc/exports lest they be confused with char‐
47 acter-class wildcard matches.
48
49 IP networks
50 You can also export directories to all hosts on an IP (sub-)
51 network simultaneously. This is done by specifying an IP address
52 and netmask pair as address/netmask where the netmask can be
53 specified in dotted-decimal format, or as a contiguous mask
54 length. For example, either `/255.255.252.0' or `/22' appended
55 to the network base IPv4 address results in identical subnet‐
56 works with 10 bits of host. IPv6 addresses must use a contiguous
57 mask length and must not be inside square brackets to avoid con‐
58 fusion with character-class wildcards. Wildcard characters gen‐
59 erally do not work on IP addresses, though they may work by ac‐
60 cident when reverse DNS lookups fail.
61
62 wildcards
63 Machine names may contain the wildcard characters * and ?, or
64 may contain character class lists within [square brackets].
65 This can be used to make the exports file more compact; for in‐
66 stance, *.cs.foo.edu matches all hosts in the domain cs.foo.edu.
67 As these characters also match the dots in a domain name, the
68 given pattern will also match all hosts within any subdomain of
69 cs.foo.edu.
70
71 netgroups
72 NIS netgroups may be given as @group. Only the host part of
73 each netgroup members is consider in checking for membership.
74 Empty host parts or those containing a single dash (-) are ig‐
75 nored.
76
77 anonymous
78 This is specified by a single * character (not to be confused
79 with the wildcard entry above) and will match all clients.
80
81 If a client matches more than one of the specifications above, then the
82 first match from the above list order takes precedence - regardless of
83 the order they appear on the export line. However, if a client matches
84 more than one of the same type of specification (e.g. two netgroups),
85 then the first match from the order they appear on the export line
86 takes precedence.
87
88 RPCSEC_GSS security
89 You may use the special strings "gss/krb5", "gss/krb5i", or "gss/krb5p"
90 to restrict access to clients using rpcsec_gss security. However, this
91 syntax is deprecated; on linux kernels since 2.6.23, you should instead
92 use the "sec=" export option:
93
94 sec= The sec= option, followed by a colon-delimited list of security
95 flavors, restricts the export to clients using those flavors.
96 Available security flavors include sys (the default--no crypto‐
97 graphic security), krb5 (authentication only), krb5i (integrity
98 protection), and krb5p (privacy protection). For the purposes
99 of security flavor negotiation, order counts: preferred flavors
100 should be listed first. The order of the sec= option with re‐
101 spect to the other options does not matter, unless you want some
102 options to be enforced differently depending on flavor. In that
103 case you may include multiple sec= options, and following op‐
104 tions will be enforced only for access using flavors listed in
105 the immediately preceding sec= option. The only options that
106 are permitted to vary in this way are ro, rw, no_root_squash,
107 root_squash, and all_squash.
108
109 Transport layer security
110 The Linux NFS server allows the use of RPC-with-TLS (RFC 9289) to pro‐
111 tect RPC traffic between itself and its clients. Alternately, adminis‐
112 trators can secure NFS traffic using a VPN, or an ssh tunnel or similar
113 mechanism, in a way that is transparent to the server.
114
115 To enable the use of RPC-with-TLS, the server's administrator must in‐
116 stall and configure tlshd to handle transport layer security handshake
117 requests from the local kernel. Clients can then choose to use RPC-
118 with-TLS or they may continue operating without it.
119
120 Administrators may require the use of RPC-with-TLS to protect access to
121 individual exports. This is particularly useful when using non-crypto‐
122 graphic security flavors such as sec=sys. The xprtsec= option, fol‐
123 lowed by an unordered colon-delimited list of security policies, can
124 restrict access to the export to only clients that have negotiated
125 transport-layer security. Currently supported transport layer security
126 policies include:
127
128 none The server permits clients to access the export without the use
129 of transport layer security.
130
131 tls The server permits clients that have negotiated an RPC-with-TLS
132 session without peer authentication (confidentiality only) to
133 access the export. Clients are not required to offer an x.509
134 certificate when establishing a transport layer security ses‐
135 sion.
136
137 mtls The server permits clients that have negotiated an RPC-with-TLS
138 session with peer authentication to access the export. The
139 server requires clients to offer an x.509 certificate when es‐
140 tablishing a transport layer security session.
141
142 If RPC-with-TLS is configured and enabled and the xprtsec= option is
143 not specified, the default setting for an export is xprt‐
144 sec=none:tls:mtls. With this setting, the server permits clients to
145 use any transport layer security mechanism or none at all to access the
146 export.
147
148 General Options
149 exportfs understands the following export options:
150
151 secure This option requires that requests not using gss originate on an
152 Internet port less than IPPORT_RESERVED (1024). This option is
153 on by default. To turn it off, specify insecure. (NOTE: older
154 kernels (before upstream kernel version 4.17) enforced this re‐
155 quirement on gss requests as well.)
156
157 rw Allow both read and write requests on this NFS volume. The de‐
158 fault is to disallow any request which changes the filesystem.
159 This can also be made explicit by using the ro option.
160
161 async This option allows the NFS server to violate the NFS protocol
162 and reply to requests before any changes made by that request
163 have been committed to stable storage (e.g. disc drive).
164
165 Using this option usually improves performance, but at the cost
166 that an unclean server restart (i.e. a crash) can cause data to
167 be lost or corrupted.
168
169
170 sync Reply to requests only after the changes have been committed to
171 stable storage (see async above).
172
173 In releases of nfs-utils up to and including 1.0.0, the async
174 option was the default. In all releases after 1.0.0, sync is
175 the default, and async must be explicitly requested if needed.
176
177 no_wdelay
178 This option has no effect if async is also set. The NFS server
179 will normally delay committing a write request to disc slightly
180 if it suspects that another related write request may be in
181 progress or may arrive soon. This allows multiple write re‐
182 quests to be committed to disc with the one operation which can
183 improve performance. If an NFS server received mainly small un‐
184 related requests, this behaviour could actually reduce perfor‐
185 mance, so no_wdelay is available to turn it off. The default
186 can be explicitly requested with the wdelay option.
187
188 nohide This option is based on the option of the same name provided in
189 IRIX NFS. Normally, if a server exports two filesystems one of
190 which is mounted on the other, then the client will have to
191 mount both filesystems explicitly to get access to them. If it
192 just mounts the parent, it will see an empty directory at the
193 place where the other filesystem is mounted. That filesystem is
194 "hidden".
195
196 Setting the nohide option on a filesystem causes it not to be
197 hidden, and an appropriately authorised client will be able to
198 move from the parent to that filesystem without noticing the
199 change.
200
201 However, some NFS clients do not cope well with this situation
202 as, for instance, it is then possible for two files in the one
203 apparent filesystem to have the same inode number.
204
205 The nohide option is currently only effective on single host ex‐
206 ports. It does not work reliably with netgroup, subnet, or
207 wildcard exports.
208
209 This option can be very useful in some situations, but it should
210 be used with due care, and only after confirming that the client
211 system copes with the situation effectively.
212
213 The option can be explicitly disabled for NFSv2 and NFSv3 with
214 hide.
215
216 This option is not relevant when NFSv4 is use. NFSv4 never
217 hides subordinate filesystems. Any filesystem that is exported
218 will be visible where expected when using NFSv4.
219
220 crossmnt
221 This option is similar to nohide but it makes it possible for
222 clients to access all filesystems mounted on a filesystem marked
223 with crossmnt. Thus when a child filesystem "B" is mounted on a
224 parent "A", setting crossmnt on "A" has a similar effect to set‐
225 ting "nohide" on B.
226
227 With nohide the child filesystem needs to be explicitly ex‐
228 ported. With crossmnt it need not. If a child of a crossmnt
229 file is not explicitly exported, then it will be implicitly ex‐
230 ported with the same export options as the parent, except for
231 fsid=. This makes it impossible to not export a child of a
232 crossmnt filesystem. If some but not all subordinate filesys‐
233 tems of a parent are to be exported, then they must be explic‐
234 itly exported and the parent should not have crossmnt set.
235
236 The nocrossmnt option can explictly disable crossmnt if it was
237 previously set. This is rarely useful.
238
239 no_subtree_check
240 This option disables subtree checking, which has mild security
241 implications, but can improve reliability in some circumstances.
242
243 If a subdirectory of a filesystem is exported, but the whole
244 filesystem isn't then whenever a NFS request arrives, the server
245 must check not only that the accessed file is in the appropriate
246 filesystem (which is easy) but also that it is in the exported
247 tree (which is harder). This check is called the subtree_check.
248
249 In order to perform this check, the server must include some in‐
250 formation about the location of the file in the "filehandle"
251 that is given to the client. This can cause problems with ac‐
252 cessing files that are renamed while a client has them open
253 (though in many simple cases it will still work).
254
255 subtree checking is also used to make sure that files inside di‐
256 rectories to which only root has access can only be accessed if
257 the filesystem is exported with no_root_squash (see below), even
258 if the file itself allows more general access.
259
260 As a general guide, a home directory filesystem, which is nor‐
261 mally exported at the root and may see lots of file renames,
262 should be exported with subtree checking disabled. A filesystem
263 which is mostly readonly, and at least doesn't see many file re‐
264 names (e.g. /usr or /var) and for which subdirectories may be
265 exported, should probably be exported with subtree checks en‐
266 abled.
267
268 The default of having subtree checks enabled, can be explicitly
269 requested with subtree_check.
270
271 From release 1.1.0 of nfs-utils onwards, the default will be
272 no_subtree_check as subtree_checking tends to cause more prob‐
273 lems than it is worth. If you genuinely require subtree check‐
274 ing, you should explicitly put that option in the exports file.
275 If you put neither option, exportfs will warn you that the
276 change is pending.
277
278
279 insecure_locks
280
281 no_auth_nlm
282 This option (the two names are synonymous) tells the NFS server
283 not to require authentication of locking requests (i.e. requests
284 which use the NLM protocol). Normally the NFS server will re‐
285 quire a lock request to hold a credential for a user who has
286 read access to the file. With this flag no access checks will
287 be performed.
288
289 Early NFS client implementations did not send credentials with
290 lock requests, and many current NFS clients still exist which
291 are based on the old implementations. Use this flag if you find
292 that you can only lock files which are world readable.
293
294 The default behaviour of requiring authentication for NLM re‐
295 quests can be explicitly requested with either of the synonymous
296 auth_nlm, or secure_locks.
297
298
299 mountpoint=path
300
301 mp This option makes it possible to only export a directory if it
302 has successfully been mounted. If no path is given (e.g.
303 mountpoint or mp) then the export point must also be a mount
304 point. If it isn't then the export point is not exported. This
305 allows you to be sure that the directory underneath a mountpoint
306 will never be exported by accident if, for example, the filesys‐
307 tem failed to mount due to a disc error.
308
309 If a path is given (e.g. mountpoint=/path or mp=/path) then the
310 nominated path must be a mountpoint for the exportpoint to be
311 exported.
312
313
314 fsid=num|root|uuid
315 NFS needs to be able to identify each filesystem that it ex‐
316 ports. Normally it will use a UUID for the filesystem (if the
317 filesystem has such a thing) or the device number of the device
318 holding the filesystem (if the filesystem is stored on the de‐
319 vice).
320
321 As not all filesystems are stored on devices, and not all
322 filesystems have UUIDs, it is sometimes necessary to explicitly
323 tell NFS how to identify a filesystem. This is done with the
324 fsid= option.
325
326 For NFSv4, there is a distinguished filesystem which is the root
327 of all exported filesystem. This is specified with fsid=root or
328 fsid=0 both of which mean exactly the same thing.
329
330 Other filesystems can be identified with a small integer, or a
331 UUID which should contain 32 hex digits and arbitrary punctua‐
332 tion.
333
334 Linux kernels version 2.6.20 and earlier do not understand the
335 UUID setting so a small integer must be used if an fsid option
336 needs to be set for such kernels. Setting both a small number
337 and a UUID is supported so the same configuration can be made to
338 work on old and new kernels alike.
339
340
341 nordirplus
342 This option will disable READDIRPLUS request handling. When
343 set, READDIRPLUS requests from NFS clients return NFS3ERR_NOT‐
344 SUPP, and clients fall back on READDIR. This option affects
345 only NFSv3 clients.
346
347 refer=path@host[+host][:path@host[+host]]
348 A client referencing the export point will be directed to choose
349 from the given list an alternative location for the filesystem.
350 (Note that the server must have a mountpoint here, though a dif‐
351 ferent filesystem is not required; so, for example, mount --bind
352 /path /path is sufficient.)
353
354 replicas=path@host[+host][:path@host[+host]]
355 If the client asks for alternative locations for the export
356 point, it will be given this list of alternatives. (Note that
357 actual replication of the filesystem must be handled elsewhere.)
358
359
360 pnfs This option enables the use of the pNFS extension if the proto‐
361 col level is NFSv4.1 or higher, and the filesystem supports pNFS
362 exports. With pNFS clients can bypass the server and perform
363 I/O directly to storage devices. The default can be explicitly
364 requested with the no_pnfs option.
365
366
367 security_label
368 With this option set, clients using NFSv4.2 or higher will be
369 able to set and retrieve security labels (such as those used by
370 SELinux). This will only work if all clients use a consistent
371 security policy. Note that early kernels did not support this
372 export option, and instead enabled security labels by default.
373
374
375 reexport=auto-fsidnum|predefined-fsidnum
376 This option helps when a NFS share is re-exported. Since the NFS
377 server needs a unique identifier for each exported filesystem
378 and a NFS share cannot provide such, usually a manual fsid is
379 needed. As soon crossmnt is used manually assigning fsid won't
380 work anymore. This is where this option becomes handy. It will
381 automatically assign a numerical fsid to exported NFS shares.
382 The fsid and path relations are stored in a SQLite database. If
383 auto-fsidnum is selected, the fsid is also autmatically allo‐
384 cated. predefined-fsidnum assumes pre-allocated fsid numbers
385 and will just look them up. This option depends also on the
386 kernel, you will need at least kernel version 5.19. Since reex‐
387 port= can automatically allocate and assign numerical fsids, it
388 is no longer possible to have numerical fsids in other exports
389 as soon this option is used in at least one export entry.
390
391 The association between fsid numbers and paths is stored in a
392 SQLite database. Don't edit or remove the database unless you
393 know exactly what you're doing. predefined-fsidnum is useful
394 when you have used auto-fsidnum before and don't want further
395 entries stored.
396
397
398
399 User ID Mapping
400 nfsd bases its access control to files on the server machine on the uid
401 and gid provided in each NFS RPC request. The normal behavior a user
402 would expect is that she can access her files on the server just as she
403 would on a normal file system. This requires that the same uids and
404 gids are used on the client and the server machine. This is not always
405 true, nor is it always desirable.
406
407 Very often, it is not desirable that the root user on a client machine
408 is also treated as root when accessing files on the NFS server. To this
409 end, uid 0 is normally mapped to a different id: the so-called anony‐
410 mous or nobody uid. This mode of operation (called `root squashing') is
411 the default, and can be turned off with no_root_squash.
412
413 By default, exportfs chooses a uid and gid of 65534 for squashed ac‐
414 cess. These values can also be overridden by the anonuid and anongid
415 options. Finally, you can map all user requests to the anonymous uid
416 by specifying the all_squash option.
417
418 Here's the complete list of mapping options:
419
420 root_squash
421 Map requests from uid/gid 0 to the anonymous uid/gid. Note that
422 this does not apply to any other uids or gids that might be
423 equally sensitive, such as user bin or group staff.
424
425 no_root_squash
426 Turn off root squashing. This option is mainly useful for disk‐
427 less clients.
428
429 all_squash
430 Map all uids and gids to the anonymous user. Useful for NFS-ex‐
431 ported public FTP directories, news spool directories, etc. The
432 opposite option is no_all_squash, which is the default setting.
433
434 anonuid and anongid
435 These options explicitly set the uid and gid of the anonymous
436 account. This option is primarily useful for PC/NFS clients,
437 where you might want all requests appear to be from one user. As
438 an example, consider the export entry for /home/joe in the exam‐
439 ple section below, which maps all requests to uid 150 (which is
440 supposedly that of user joe).
441
442
443 Subdirectory Exports
444 Normally you should only export only the root of a filesystem. The NFS
445 server will also allow you to export a subdirectory of a filesystem,
446 however, this has drawbacks:
447
448 First, it may be possible for a malicious user to access files on the
449 filesystem outside of the exported subdirectory, by guessing filehan‐
450 dles for those other files. The only way to prevent this is by using
451 the no_subtree_check option, which can cause other problems.
452
453 Second, export options may not be enforced in the way that you would
454 expect. For example, the security_label option will not work on subdi‐
455 rectory exports, and if nested subdirectory exports change the secu‐
456 rity_label or sec= options, NFSv4 clients will normally see only the
457 options on the parent export. Also, where security options differ, a
458 malicious client may use filehandle-guessing attacks to access the
459 files from one subdirectory using the options from another.
460
461
462
463 Extra Export Tables
464 After reading /etc/exports exportfs reads files in the /etc/exports.d
465 directory as extra export tables. Only files ending in .exports are
466 considered. Files beginning with a dot are ignored. The format for
467 extra export tables is the same as /etc/exports
468
470 # sample /etc/exports file
471 / master(rw) trusty(rw,no_root_squash)
472 /projects proj*.local.domain(rw)
473 /usr *.local.domain(ro) @trusted(rw)
474 /home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
475 /pub *(ro,insecure,all_squash)
476 /srv/www -sync,rw server @trusted @external(ro)
477 /foo 2001:db8:9:e54::/64(rw) 192.0.2.0/24(rw)
478 /build buildhost[0-9].local.domain(rw)
479
480 The first line exports the entire filesystem to machines master and
481 trusty. In addition to write access, all uid squashing is turned off
482 for host trusty. The second and third entry show examples for wildcard
483 hostnames and netgroups (this is the entry `@trusted'). The fourth line
484 shows the entry for the PC/NFS client discussed above. Line 5 exports
485 the public FTP directory to every host in the world, executing all re‐
486 quests under the nobody account. The insecure option in this entry also
487 allows clients with NFS implementations that don't use a reserved port
488 for NFS. The sixth line exports a directory read-write to the machine
489 'server' as well as the `@trusted' netgroup, and read-only to netgroup
490 `@external', all three mounts with the `sync' option enabled. The sev‐
491 enth line exports a directory to both an IPv6 and an IPv4 subnet. The
492 eighth line demonstrates a character class wildcard match.
493
495 /etc/exports /etc/exports.d
496
498 exportfs(8), netgroup(5), mountd(8), nfsd(8), showmount(8), tlshd(8).
499
500
501
502 31 December 2009 exports(5)