exports — NFS server access policy
/etc/exports and supported .exports snippets declare which clients may access server directories. Client specifications and parenthesized options must be adjacent: inserting whitespace can change which clients receive the options. ro denies writes at export level; sync commits changes before replying under its semantics; root_squash maps client root to an anonymous identity and is normally default. It does not authenticate users or encrypt traffic; evaluate NFS version, sec settings, identity mapping and network trust. Client matching precedence depends first on the client specification type; among matches of the same type, the first listed match on that export line wins. Avoid wildcard exports and broad writable shares. The example extracts a fictional documentation subnet and read-only options; it does not validate NFS authorization. In a disposable VM review the effective export table, test permitted and denied clients and filesystem permissions, then restore prior policy and reconcile actual exports if needed. Do not run exportfs -ra merely to check syntax; it changes exports.
Formal Syntax & Structure
/srv/example 192.0.2.0/24(ro,sync,root_squash)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| directory | directive or field | Exported path |
| clients | directive or field | Authorized client specification |
| options | directive or field | Access and security options |
Return Value
Export policy declaration, not mounted or exported storage.
Working Example
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITprintf '/srv/example 192.0.2.0/24(ro,sync,root_squash)\n' > "$d/exports"awk 'NF==2 && $2 ~ /\(ro,sync,root_squash\)$/ {print "path=" $1, "client=" $2}' "$d/exports"