Fundamentals 16 min read

Master NFS: From Protocol Basics to Full CentOS 7 Deployment

This guide explains the NFS protocol fundamentals, activation steps, version comparisons, and provides a step‑by‑step CentOS 7 installation and configuration tutorial, including service setup, firewall adjustments, export file editing, and client mounting procedures.

Open Source Linux
Open Source Linux
Open Source Linux
Master NFS: From Protocol Basics to Full CentOS 7 Deployment

Table of Contents

NFS Protocol

NFS Service

Practical Demonstration

1. NFS Protocol

NFS service works on TCP port 2049 and UDP port 2049 .

NFS (Network File System) is a distributed file system protocol that allows different machines and operating systems to share files over a network, making remote directories appear as local partitions.

1.1 Working Principle

NFS relies on RPC (Remote Procedure Call) to assign dynamic ports (numbers below 1024) and register services, enabling clients to discover the correct ports.

RPC acts as the transport layer for NFS, providing port mapping and authentication.

How does RPC know each NFS port?

When NFS starts, it randomly selects ports and registers them with RPC, which listens on port 111.

RPC must be started before NFS; if RPC restarts, NFS services must be restarted to re‑register.

How does the client exchange data with the NFS server?

Client queries RPC port 111 for NFS service.

Server returns the specific NFS daemon port.

Client connects directly to that daemon.

1.2 Activating NFS Service

NFS service requires several RPC daemons.

Workflow

nfs-client => portmapper => mountd => nfs-server (nfsd)

Key daemons: rpc.nfsd: manages client login permissions. rpc.mountd: handles NFS file system exports and provides access tokens via portmapper (port 1111).

1.3 Version Comparison

NFS has three major versions released since 1985: NFSv2, NFSv3, and NFSv4 (with sub‑versions 4.0 and 4.1). Sun originally authored v2/v3; NetApp drove v4 development.

NFSv2

First RFC version, basic functionality.

NFSv3

Supports asynchronous writes and an ACCESS request for permission checks.

Improved parameter handling over v2.

NFSv4.0

Stateful protocol with built‑in file locking and root export.

Adds RPCSEC‑GSS security and uses COMPOUND requests.

Changes namespace requiring a root export (fsid=0).

Supports delegation for client‑side caching.

NFSv4.1

Introduces parallel storage with separate metadata (MDS) and data (DS) servers, improving scalability.

2. NFS Service on CentOS 7

CentOS 7 uses NFSv4 over TCP port 2049 by default.
# System environment
System platform: CentOS release 7.0 (Final)
NFS Server IP: 192.168.10.10
Firewall: not running
SELINUX=disabled

2.1 Install NFS Service

Server

Packages: nfs-utils, rpcbind (usually pre‑installed).

Check files with rpm -ql nfs-utils.

Client

Install nfs-utils for client tools.

# yum install nfs-utils
Loaded plugins: langpacks, product-id, subscription-manager
... (output) ...
Package 1:nfs-utils-1.3.0-0.el7.x86_64 already installed and latest version
Nothing to do

2.2 Service Configuration

Fix NFS ports by editing /etc/sysconfig/nfs (e.g., RQUOTAD_PORT=30001, LOCKD_TCPPORT=30002, LOCKD_UDPPORT=30002, MOUNTD_PORT=30003, STATD_PORT=30004).

View current RPC ports with rpcinfo -p localhost.

# rpcinfo -p localhost
program vers proto port service
100000 4 tcp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 49979 mountd
100005 1 tcp 58393 mountd
100003 2 tcp 2049 nfs
100227 2 tcp 2049 nfs_acl
...

2.3 Start and Enable Services

# service nfs start
Starting NFS services:        [OK]
Starting NFS quotas:          [OK]
Starting NFS mountd:          [OK]
Starting NFS daemon:          [OK]
Starting NFS idmapd:          [OK]
# systemctl restart rpcbind
# systemctl enable rpcbind
# systemctl start nfs-server
# systemctl enable nfs-server

2.4 Export File Configuration

Define shared directories in /etc/exports with syntax “ (options)”. Example:

/nfsfile 192.168.10.*(rw,sync,root_squash)

2.5 Client Mounting

List exports with showmount -e SERVER_IP.

Mount with mount -t nfs SERVER:/nfsfile /nfsfile.

Add to /etc/fstab for persistent mounts.

# showmount -e 192.168.10.10
Export list for 192.168.10.10:
/nfsfile 192.168.10.*
# mount -t nfs 192.168.10.10:/nfsfile /nfsfile
# cat /etc/fstab
... 
192.168.10.10:/nfsfile /nfsfile nfs defaults 0 0
Author: Escape Link: https://escapelife.github.io/posts/c49dfbab.html Compiled by WeChat public account “Open Source Linux”.
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RPCLinuxNFSCentOSNetwork File System
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.