1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.Dd October 08, 2024 29.Dt EXPORTS 5 30.Os 31.Sh NAME 32.Nm exports 33.Nd define remote mount points for 34.Tn NFS 35mount requests 36.Sh SYNOPSIS 37.Nm 38.Sh DESCRIPTION 39The 40.Nm 41file specifies remote mount points for the 42.Tn NFS 43mount protocol per the 44.Tn NFS 45server specification; see 46.%T "Network File System Protocol Specification" , 47RFC1094, Appendix A and 48.%T "NFS: Network File System Version 3 Specification" , 49Appendix I. 50.Pp 51Each line in the file 52(other than comment lines that begin with a #) 53specifies the mount point(s) and export flags within one local server 54file system or the NFSv4 tree root for one or more hosts. 55A long line may be split over several lines by ending all but the 56last line with a backslash 57.Pq Ql \e . 58A host may be specified only once for each local file system or the NFSv4 tree 59root on the server and there may be only one default entry for each server 60file system that applies to all other hosts. 61The latter exports the file system to the 62.Dq world 63and should 64be used only when the file system contains public information. 65.Pp 66In a mount entry, 67the first field(s) specify the directory path(s) within a server file system 68that can be mounted on by the corresponding client(s). 69Note well that exporting a directory on the server does not guarantee that only 70files below the exported directory will be accessible. 71This is true even in the absence of the 72.Fl alldirs 73flag. 74To provide this guarantee, the exported directories must be local file system 75mount points on the server. 76For example, if one exports 77.Pa /home , 78and 79.Pa /home 80is not a file system mount point, then clients will be able to access arbitrary 81files on the root file system. 82As such, to avoid confusion with respect to what is exported, it may be prudent 83to limit exported directories to server local file system mount points. 84When exporting ZFS datasets with the 85.Sy sharenfs 86property, this is auomatically the case. 87.Pp 88There are three forms of the directory path specification. 89The first is to list all mount points as absolute 90directory paths separated by whitespace. 91This list of directory paths should be considered an 92.Dq administrative control , 93since it is only enforced by the 94.Xr mountd 8 95daemon and not the kernel. 96As such, it only applies to NFSv2 and NFSv3 mounts and only 97with respect to the client's use of the mount protocol. 98The second is to specify the pathname of the root of the file system 99followed by the 100.Fl alldirs 101flag; 102this form allows the host(s) to mount at any point within the file system, 103including regular files if the 104.Fl r 105option is used on 106.Xr mountd 8 . 107Because NFSv4 does not use the mount protocol, 108the 109.Dq administrative controls 110are not applied and all directories within this server 111file system are mountable via NFSv4 even if the 112.Fl alldirs 113flag has not been specified. 114The third form has the string ``V4:'' followed by a single absolute path 115name, to specify the NFSv4 tree root. 116This line does not export any file system, but simply marks where the root 117of the server's directory tree is for NFSv4 clients. 118The exported file systems for NFSv4 are specified via the other lines 119in the 120.Nm 121file in the same way as for NFSv2 and NFSv3. 122The pathnames must not have any symbolic links in them and should not have 123any 124.Dq Pa \&. 125or 126.Dq Pa .. 127components. 128Pathnames are decoded by 129.Xr strunvis 3 130allowing special characters to be included in the directory name(s). 131In particular, whitespace, such as embedded blanks in directory names 132can be handled. 133For example, a blank can be encoded as \(rs040. 134.Xr vis 1 135with the 136.Fl M 137option may be used to encode directory name(s) with embedded special 138characters. 139Mount points for a file system may appear on multiple lines each with 140different sets of hosts and export options. 141.Pp 142The second component of a line specifies how the file system is to be 143exported to the host set. 144The option flags specify whether the file system 145is exported read-only or read-write and how the client UID is mapped to 146user credentials on the server. 147For the NFSv4 tree root, the only options that can be specified in this 148section are ones related to security: 149.Fl sec , 150.Fl tls , 151.Fl tlscert 152and 153.Fl tlscertuser . 154.Pp 155Export options are specified as follows: 156.Pp 157.Sm off 158.Fl maproot Li = Sy user 159.Sm on 160The credential of the specified user is used for remote access by root. 161The credential includes all the groups to which the user is a member 162on the local machine (see 163.Xr id 1 ) . 164The user may be specified by name or number. 165The user string may be quoted, or use backslash escaping. 166.Pp 167.Sm off 168.Fl maproot Li = Sy user:group1:group2:... 169.Sm on 170The colon separated list is used to specify the precise credential 171to be used for remote access by root. 172The elements of the list may be either names or numbers. 173Note that 174.Cm user: 175should be used to specify a credential containing no groups, in which case the 176established credential will use 177.Ql nogroup , 178else 65533 179.Pq Dv GID_NOGROUP , 180as the fallback group 181.Pq a credential object must have at least one group internally . 182Using just 183.Cm user 184.Pq without colon at end 185falls into the 186.Sm off 187.Fl maproot Li = Sy user 188.Sm on 189case described above. 190The group names may be quoted, or use backslash escaping. 191.Pp 192.Sm off 193.Fl mapall Li = Sy user 194.Sm on 195or 196.Sm off 197.Fl mapall Li = Sy user:group1:group2:... 198.Sm on 199specifies a mapping for all client UIDs (including root) 200using the same semantics as 201.Fl maproot . 202.Pp 203The option 204.Fl r 205is a synonym for 206.Fl maproot 207in an effort to be backward compatible with older export file formats. 208.Pp 209In the absence of 210.Fl maproot 211and 212.Fl mapall 213options, remote accesses by root will result in using a credential of 65534:65533. 214All other users will be mapped to their remote credential. 215If a 216.Fl maproot 217option is given, 218remote access by root will be mapped to that credential instead of 65534:65533. 219If a 220.Fl mapall 221option is given, 222all users (including root) will be mapped to that credential in 223place of their own. 224.Pp 225.Sm off 226.Fl sec Li = Sy flavor1:flavor2... 227.Sm on 228specifies a colon separated list of acceptable security flavors to be 229used for remote access. 230Supported security flavors are sys, krb5, krb5i and krb5p. 231If multiple flavors are listed, they should be ordered with the most 232preferred flavor first. 233If this option is not present, 234the default security flavor list of just sys is used. 235.Pp 236The 237.Fl ro 238option specifies that the file system should be exported read-only 239(default read/write). 240The option 241.Fl o 242is a synonym for 243.Fl ro 244in an effort to be backward compatible with older export file formats. 245.Pp 246.Tn WebNFS 247exports strictly according to the spec (RFC 2054 and RFC 2055) can 248be done with the 249.Fl public 250flag. 251However, this flag in itself allows r/w access to all files in 252the file system, not requiring reserved ports and not remapping UIDs. 253It 254is only provided to conform to the spec, and should normally not be used. 255For a 256.Tn WebNFS 257export, 258use the 259.Fl webnfs 260flag, which implies 261.Fl public , 262.Sm off 263.Fl mapall No = Sy nobody 264.Sm on 265and 266.Fl ro . 267Note that only one file system can be 268.Tn WebNFS 269exported on a server. 270.Pp 271A 272.Sm off 273.Fl index No = Pa file 274.Sm on 275option can be used to specify a file whose handle will be returned if 276a directory is looked up using the public filehandle 277.Pq Tn WebNFS . 278This is to mimic the behavior of URLs. 279If no 280.Fl index 281option is specified, a directory filehandle will be returned as usual. 282The 283.Fl index 284option only makes sense in combination with the 285.Fl public 286or 287.Fl webnfs 288flags. 289.Pp 290The 291.Fl tls , 292.Fl tlscert 293and 294.Fl tlscertuser 295export options are used to require the client to use TLS for the mount(s) 296per RFC 9289. 297For NFS mounts using TLS to work, 298.Xr rpc.tlsservd 8 299must be running on the server. 300.Bd -filled -offset indent 301.Fl tls 302requires that the client use TLS. 303.br 304.Fl tlscert 305requires that the client use TLS and provide a verifiable X.509 certificate 306during TLS handshake. 307.br 308.Fl tlscertuser 309requires that the client use TLS and provide a verifiable X.509 certificate. 310The otherName component of the certificate's subjAltName must have a 311an OID of 1.3.6.1.4.1.2238.1.1.1 and a UTF8 string of the form 312.Dq user@domain . 313.Dq user@domain 314will be translated to the credentials of the specified user in the same 315manner as 316.Xr nfsuserd 8 , 317where 318.Dq user 319is normally a username is the server's password database and 320.Dq domain 321is the DNS domain name for the server. 322All RPCs will be performed using these credentials instead of the 323ones in the RPC header in a manner similar to 324.Sm off 325.Fl mapall Li = Sy user . 326.Sm on 327.Ed 328.Pp 329If none of these three flags are specified, TLS mounts are permitted but 330not required. 331.Pp 332Specifying the 333.Fl quiet 334option will inhibit some of the syslog diagnostics for bad lines in 335.Pa /etc/exports . 336This can be useful to avoid annoying error messages for known possible 337problems (see 338.Sx EXAMPLES 339below). 340.Pp 341The third component of a line specifies the host set to which the line applies. 342The set may be specified in three ways. 343The first way is to list the host name(s) separated by white space. 344(Standard Internet 345.Dq dot 346addresses may be used in place of names.) 347The second way is to specify a 348.Dq netgroup 349as defined in the 350.Pa netgroup 351file (see 352.Xr netgroup 5 ) . 353The third way is to specify an Internet subnetwork using a network and 354network mask that is defined as the set of all hosts with addresses within 355the subnetwork. 356This latter approach requires less overhead within the 357kernel and is recommended for cases where the export line refers to a 358large number of clients within an administrative subnet. 359.Pp 360The first two cases are specified by simply listing the name(s) separated 361by whitespace. 362All names are checked to see if they are 363.Dq netgroup 364names 365first and are assumed to be hostnames otherwise. 366Using the full domain specification for a hostname can normally 367circumvent the problem of a host that has the same name as a netgroup. 368The third case is specified by the flag 369.Sm off 370.Fl network Li = Sy netname Op Li / Ar prefixlength 371.Sm on 372and optionally 373.Sm off 374.Fl mask No = Sy netmask . 375.Sm on 376The netmask may be specified either by attaching a 377.Ar prefixlength 378to the 379.Fl network 380option, or by using a separate 381.Fl mask 382option. 383If the mask is not specified, it will default to the historical mask 384for that network class (A, B, or C; see 385.Xr inet 4 ) . 386This usage is deprecated, and will elicit a warning log message. 387See the 388.Sx EXAMPLES 389section below. 390.Pp 391Scoped IPv6 address must carry scope identifier as documented in 392.Xr inet6 4 . 393For example, 394.Dq Li fe80::%re2/10 395is used to specify 396.Li fe80::/10 397on 398.Li re2 399interface. 400.Pp 401For the third form which specifies the NFSv4 tree root, the directory path 402specifies the location within the server's file system tree which is the 403root of the NFSv4 tree. 404There can only be one NFSv4 root directory per server. 405As such, all entries of this form must specify the same directory path. 406For file systems other than ZFS, 407this location can be any directory and does not 408need to be within an exported file system. 409If it is not in an exported file system, a very limited set of operations 410are permitted, so that an NFSv4 client can traverse the tree to an 411exported file system. 412Although parts of the NFSv4 tree can be non-exported, the entire NFSv4 tree 413must consist of local file systems capable of being exported via NFS. 414All ZFS file systems in the subtree below the NFSv4 tree root must be 415exported. 416NFSv4 does not use the mount protocol and does permit clients to cross server 417mount point boundaries, although not all clients are capable of crossing the 418mount points. 419.Pp 420The 421.Fl sec 422option on these line(s) specifies what security flavors may be used for 423NFSv4 operations that do not use file handles. 424Since these operations (SetClientID, SetClientIDConfirm, Renew, DelegPurge 425and ReleaseLockOnwer) allocate/modify state in the server, it is possible 426to restrict some clients to the use of the krb5[ip] security flavors, 427via this option. 428See the 429.Sx EXAMPLES 430section below. 431This third form is meaningless for NFSv2 and NFSv3 and is ignored for them. 432.Pp 433The 434.Xr mountd 8 435utility can be made to re-read the 436.Nm 437file by sending it a hangup signal as follows: 438.Bd -literal -offset indent 439service mountd reload 440.Ed 441.Pp 442After sending the 443.Dv SIGHUP , 444check the 445.Xr syslogd 8 446output to see whether 447.Xr mountd 8 448logged any parsing errors in the 449.Nm 450file. 451.Sh FILES 452.Bl -tag -width /etc/exports -compact 453.It Pa /etc/exports 454the default remote mount-point file 455.El 456.Sh EXAMPLES 457Given that 458.Pa /usr , /u , /a 459and 460.Pa /u2 461are 462local file system mount points, let's consider the following example: 463.Pp 464.Bd -literal -offset indent 465/usr /usr/local -maproot=0:10 friends 466/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16 467/usr -ro -mapall=nobody 468/u -maproot=bin: -network 131.104.48 -mask 255.255.255.0 469/a -network 192.168.0/24 470/a -network 3ffe:1ce1:1:fe80::/64 471/u2 -maproot=root friends 472/u2 -alldirs -network cis-net -mask cis-mask 473/cdrom -alldirs,quiet,ro -network 192.168.33.0 -mask 255.255.255.0 474/private -sec=krb5i 475/secret -sec=krb5p 476V4: / -sec=krb5:krb5i:krb5p -network 131.104.48 -mask 255.255.255.0 477V4: / -sec=sys:krb5:krb5i:krb5p grumpy.cis.uoguelph.ca 478.Ed 479.Pp 480The file systems rooted at 481.Pa /usr 482and 483.Pa /usr/local 484are exported to hosts within the 485.Dq friends 486network group 487with users mapped to their remote credentials and 488root mapped to UID 0 and group 10. 489They are exported read-write and the hosts in 490.Dq friends . 491.Pp 492The file system rooted at 493.Pa /usr 494is exported to 495.Em 131.104.48.16 496and 497.Em grumpy.cis.uoguelph.ca 498with users mapped to their remote credentials and 499root mapped to the user and groups associated with 500.Dq daemon ; 501it is exported to the rest of the world as read-only with 502all users mapped to the user and groups associated with 503.Dq nobody . 504.Pp 505The file system rooted at 506.Pa /u 507is exported to all hosts on the subnetwork 508.Em 131.104.48 509with root mapped to the UID for 510.Dq bin 511and with no group access. 512.Pp 513The file system rooted at 514.Pa /u2 515is exported to the hosts in 516.Dq friends 517with root mapped to UID and groups 518associated with 519.Dq root ; 520it is exported to all hosts on network 521.Dq cis-net 522allowing mounts at any 523directory within /u2. 524.Pp 525The file system rooted at 526.Pa /a 527is exported to the network 192.168.0.0, with a netmask of 255.255.255.0. 528However, the netmask length in the entry for 529.Pa /a 530is not specified through a 531.Fl mask 532option, but through the 533.Li / Ns Ar prefix 534notation. 535.Pp 536The file system rooted at 537.Pa /a 538is also exported to the IPv6 network 539.Li 3ffe:1ce1:1:fe80:: 540address, using the upper 64 bits as the prefix. 541Note that, unlike with IPv4 network addresses, the specified network 542address must be complete, and not just contain the upper bits. 543With IPv6 addresses, the 544.Fl mask 545option must not be used. 546.Pp 547The file system rooted at 548.Pa /cdrom 549will be exported read-only to the entire network 192.168.33.0/24, including 550all its subdirectories. 551Since 552.Pa /cdrom 553is the conventional mountpoint for a CD-ROM device, this export will 554fail if no CD-ROM medium is currently mounted there since that line 555would then attempt to export a subdirectory of the root file system 556with the 557.Fl alldirs 558option which is not allowed. 559The 560.Fl quiet 561option will then suppress the error message for this condition that 562would normally be syslogged. 563As soon as an actual CD-ROM is going to be mounted, 564.Xr mount 8 565will notify 566.Xr mountd 8 567about this situation, and the 568.Pa /cdrom 569file system will be exported as intended. 570Note that without using the 571.Fl alldirs 572option, the export would always succeed. 573While there is no CD-ROM medium mounted under 574.Pa /cdrom , 575it would export the (normally empty) directory 576.Pa /cdrom 577of the root file system instead. 578.Pp 579The file system rooted at 580.Pa /private 581will be exported using Kerberos 5 authentication and will require 582integrity protected messages for all accesses. 583The file system rooted at 584.Pa /secret 585will also be exported using Kerberos 5 authentication and all messages 586used to access it will be encrypted. 587.Pp 588For the experimental server, the NFSv4 tree is rooted at ``/'', 589and any client within the 131.104.48 subnet is permitted to perform NFSv4 state 590operations on the server, so long as valid Kerberos credentials are provided. 591The machine grumpy.cis.uoguelph.ca is permitted to perform NFSv4 state 592operations on the server using AUTH_SYS credentials, as well as Kerberos ones. 593.Pp 594In the following example some directories are exported as NFSv3 and NFSv4: 595.Bd -literal -offset indent 596V4: /wingsdl/nfsv4 597/wingsdl/nfsv4/usr-ports -maproot=root -network 172.16.0.0 -mask 255.255.0.0 598/wingsdl/nfsv4/clasper -maproot=root clasper 599.Ed 600.Pp 601Only one V4: line is needed or allowed to declare where NFSv4 is 602rooted. 603The other lines declare specific exported directories with 604their absolute paths given in /etc/exports. 605.Pp 606The exported directories' paths are used for both v3 and v4. 607However, they are interpreted differently for v3 and v4. 608A client mount command for usr-ports would use the server-absolute name when 609using nfsv3: 610.Bd -literal -offset indent 611mount server:/wingsdl/nfsv4/usr-ports /mnt/tmp 612.Ed 613.Pp 614A mount command using NFSv4 would use the path relative to the NFSv4 615root: 616.Bd -literal -offset indent 617mount server:/usr-ports /mnt/tmp 618.Ed 619.Pp 620This also differentiates which version you want if the client can do 621both v3 and v4. 622The former will only ever do a v3 mount and the latter will only ever 623do a v4 mount. 624.Pp 625Note that due to different mount behavior between NFSv3 and NFSv4 a 626NFSv4 mount request for a directory that the client does not have 627permission for will succeed and read/write access will fail 628afterwards, whereas NFSv3 rejects the mount request. 629.Sh SEE ALSO 630.Xr vis 1 , 631.Xr strunvis 3 , 632.Xr nfsv4 4 , 633.Xr netgroup 5 , 634.Xr zfsprops 7 , 635.Xr mountd 8 , 636.Xr nfsd 8 , 637.Xr rpc.tlsservd 8 , 638.Xr service 8 , 639.Xr showmount 8 640.Sh STANDARDS 641The implementation is based on the following documents: 642.Bl -dash 643.It 644.Rs 645.%T "Network File System Protocol Specification, Appendix A, RFC 1094" 646.Re 647.It 648.Rs 649.%T "NFS: Network File System Version 3, Appendix I, RFC 1813" 650.Re 651.It 652.Rs 653.%T "Towards Remote Procedure Call Encryption by Default, RFC 9289" 654.Re 655.El 656.Sh BUGS 657The export options are tied to the local mount points in the kernel and 658must be non-contradictory for any exported subdirectory of the local 659server mount point. 660It is recommended that all exported directories within the same server 661file system be specified on adjacent lines going down the tree. 662You cannot specify a hostname that is also the name of a netgroup. 663Specifying the full domain specification for a hostname can normally 664circumvent the problem. 665