Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
On the server:
dnf -y install nfs-utils
mkdir -p /srv/share && chown 2001:2001 /srv/share
echo '/srv/share 10.0.1.0/24(rw,sync,root_squash)' > /etc/exports.d/share.exports
systemctl enable --now nfs-server
exportfs -rav
firewall-cmd --permanent --add-service=nfs && firewall-cmd --reloadOn the client:
On Ubuntu: nfs-kernel-server (server) and nfs-common (client).
Step by step
- Export only to the clients that need it — never
*:
| Option | Means |
|---|---|
10.0.1.0/24 | Only this network may mount. |
rw / ro | Read-write / read-only. |
sync | Write to disk before answering (safe; async is faster but can lose data). |
root_squash | Root on the client becomes nobody on the server (default — keep it). |
all_squash,anonuid=2001,anongid=2001 | Every client user maps to one owner — simple for shared app data. |
- Apply and check the exports:
- User IDs decide access — NFS checks the numbers (UID/GID), not the names. User
appwith UID 2001 on the server and UID 1005 on the client are different users for NFS. Use the same UIDs everywhere (orall_squash+anonuid, or central users via IdM/LDAP). - Mount at boot on the client —
_netdevwaits for the network,nofailkeeps the boot going if the server is down:
nfs1.example.com:/srv/share /mnt/share nfs4 defaults,_netdev,nofail 0 0For shares that are not always needed, autofs mounts them only on access.
- SELinux on the client — web servers reading from NFS need:
setsebool -P httpd_use_nfs onCheck that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
mount.nfs4: access denied by server | Client IP not in the export, or no exportfs -r. | Fix /etc/exports.d/…; exportfs -rav. |
Permission denied when writing | UID/GID differ, or root_squash for root. | Same UIDs; all_squash + anonuid; do not write as root. |
Files owned by nobody | UID mapping / idmapd domain mismatch. | Same Domain in /etc/idmapd.conf on both sides; same UIDs. |
mount.nfs4: Connection timed out | Firewall (2049/tcp) or server down. | firewall-cmd --add-service=nfs; nc -zv nfs1 2049. |
| Boot hangs on the NFS mount | No _netdev/nofail. | Add them, or use autofs. |
showmount -e does not work | NFSv4-only server (no rpcbind/mountd). | Normal — mount the path directly. |
Go further
- Command pages: exportfs, mount, showmount, findmnt.
- Next how-tos: Mount a Windows or Samba share, Mount a disk at boot with fstab, Open a port in the firewall, Mount network folders on demand with autofs.
- Full guide: NFS server and clients. Learn it: RHCSA — NFS server, RHCSA — autofs, RH134 — NFS troubleshooting.
- Practise: Lab: NFS server, fstab and autofs.
1Why can user app write on one client but not on another?
NFS checks UID/GID numbers; app probably has a different UID on the other client.
2What does root_squash do?
Root on the client is mapped to nobody on the server, so client root can not act as server root.