259 words
1 minutes
Network File System (NFS)

Network File System (NFS)#

๐Ÿ“Œ Overview#

  • NFS is developed by Sun Microsystems to access files over a network as if they were local.
  • Primarily used between Linux/Unix systems, unlike SMB, which is used by Windows.
  • NFSv3 authenticates the client computer, while NFSv4 authenticates the user (like SMB).
  • Governed by the Internet standard for distributed file systems.

๐Ÿ”ข NFS Versions & Features#

VersionFeatures
NFSv2Old version, supports many systems, uses UDP.
NFSv3Supports variable file sizes, better error reporting, backward incompatible with NFSv2.
NFSv4Supports Kerberos, firewalls, Internet; adds ACLs, state-based ops, high security.
NFSv4.1Adds cluster support, pNFS, session trunking (multipathing), and simplifies firewall configs using port 2049 only.

๐Ÿ” Authentication & Authorization#

  • Based on ONC-RPC (SUN-RPC) protocol.
  • Uses XDR for platform-independent data exchange.
  • Authentication via RPC, usually through UID/GID and group memberships.
  • UID/GID mismatch across client and server can lead to access issues.
  • Best used in trusted networks.

๐Ÿ“ Common Options#

OptionDescription
rwRead/write access
roRead-only access
syncSynchronous data transfer (safer)
asyncAsynchronous (faster, less safe)
secureUses ports below 1024
insecureAllows ports above 1024
no_subtree_checkDisables subtree validation
root_squashMaps root UID/GID to anonymous (prevents root access)

โš ๏ธ Dangerous Settings#

OptionRisk
rwFull access to files
insecureAllows user-mode programs to access NFS
nohideExposes sub-mounted filesystems unintentionally
no_root_squashGrants root full access โ€” security risk

๐Ÿ› ๏ธ Managing Exports#

# Add entry
echo '/mnt/nfs 10.129.14.0/24(sync,no_subtree_check)' >> /etc/exports

# Restart NFS service
systemctl restart nfs-kernel-server

# View exports
exportfs

๐Ÿ•ต๏ธ Footprinting NFS#

๐Ÿ“Œ Important Ports#

  • TCP/UDP 111 (rpcbind)
  • TCP/UDP 2049 (nfs)

๐Ÿ” Nmap Scanning#

Basic scan for services:

sudo nmap 10.129.14.128 -p111,2049 -sV -sC

Nmap NSE scripts:

sudo nmap --script nfs* 10.129.14.128 -sV -p111,2049

Useful Outputs:

  • List of mounted shares
  • File listing (nfs-ls)
  • Share details (nfs-showmount)
  • Filesystem stats (nfs-statfs)
  • Running RPC services (rpcinfo)

๐Ÿงช Practical Tips#

  • Create different folders with various settings to test NFS permissions and enumeration.
  • Pay attention to port configurations and root access options.
  • Use Nmap scripts for detailed service analysis.