VMoreCloud › Linux › Ubuntu › Network File System
Ubuntu NFS Network File System Ubuntu Server Linux Networking

How to Set Up Ubuntu Network File System (NFS) Server and Client

Learn how to configure an Ubuntu Network File System (NFS) server, export shared directories, connect Ubuntu clients, configure persistent mounts, secure access and troubleshoot common NFS problems.

Author: Khurram Shahzad Published: October 2, 2026 Updated: October 2, 2026 Category: Linux / Ubuntu Reading time: 12–15 minutes

Build a Centralized Ubuntu NFS File Share

NFS allows an Ubuntu server to export directories over the network so authorized Linux clients can mount those directories and work with remote files as though they were part of the local filesystem.

$ sudo apt install nfs-kernel-server

$ sudo exportfs -ra

$ sudo mount
192.168.1.10:/srv/nfs /mnt/nfs
01

Install NFS Server

Install the Ubuntu NFS server package and create the directory you want to share.

02

Configure Exports

Use /etc/exports to define which clients can access the exported directory.

03

Mount the Share

Install NFS client utilities and mount the remote export on the Ubuntu client.

04

Make It Persistent

Configure /etc/fstab so the NFS share can be mounted automatically after reboot.

Important: NFS access is controlled by both network/export rules and normal Linux filesystem permissions. Do not export sensitive directories to an entire network unless that access is intentional. Use the narrowest client IP or subnet that meets your requirements.

How to Set Up Ubuntu Network File System (NFS)

Network File System (NFS) is a network filesystem protocol that allows one Linux system to share directories with other systems over a network. On Ubuntu, an NFS server exports a directory, while an NFS client mounts that export into its local filesystem.

This makes NFS useful for centralized storage, Linux home directories, application data, virtualization environments, development labs, backup repositories and shared files between Ubuntu servers.

In this tutorial, we will build a complete Ubuntu NFS environment using one Ubuntu server and one Ubuntu client. The example configuration uses a private network and restricts access to the client subnet rather than exposing the share to every host.

What Is Ubuntu Network File System?

Ubuntu Network File System refers to using NFS on Ubuntu systems to provide network-based filesystem access. The server makes a directory available through an NFS export, and the client mounts that export at a local directory.

After mounting, applications on the client can normally access the remote directory using standard filesystem operations such as reading, writing, creating and deleting files, subject to the permissions configured on both systems.

Component Purpose Ubuntu Package / Configuration
NFS Server Exports directories to authorized clients. nfs-kernel-server
NFS Client Mounts and accesses remote NFS exports. nfs-common
Export Configuration Defines which clients can access shared directories. /etc/exports
Persistent Mounts Mounts NFS shares automatically through system configuration. /etc/fstab

Ubuntu NFS Server and Client Architecture

The basic NFS architecture is simple: the server owns the physical data and exports a directory, while the client connects to that export and mounts it locally.

Ubuntu NFS Server 192.168.1.10
/srv/nfs
→
Ubuntu NFS Client 192.168.1.20
/mnt/nfs

In this example, the server address is 192.168.1.10 and the client address is 192.168.1.20. These are examples; replace them with the addresses used in your own environment.

Requirements and Lab Setup

Before configuring NFS, prepare two Ubuntu systems that can communicate with each other over the network.

NFS Server

  • Ubuntu Server installation
  • Static or reserved IP address recommended
  • Administrative sudo access
  • Storage available for the shared directory
  • Network connectivity to clients

NFS Client

  • Ubuntu or compatible Linux system
  • Network connectivity to the NFS server
  • Administrative sudo access
  • Empty mount point directory
  • Compatible user/group permissions
Recommended: Give the NFS server a stable IP address. If the server address changes, clients using an IP address in /etc/fstab may no longer be able to mount the share.

Step 1: Install the NFS Server on Ubuntu

1

Update the Ubuntu Package Index

sudo apt update
2

Install the NFS Server Package

sudo apt install nfs-kernel-server

Ubuntu’s current server documentation uses nfs-kernel-server for installing the NFS server functionality.

3

Check the NFS Service

sudo systemctl status nfs-server

If required, start the service with:

sudo systemctl start nfs-server

Step 2: Create the NFS Shared Directory

The directory exported by NFS can reside on a local disk, RAID array, storage volume or another filesystem mounted on the Ubuntu server.

For this tutorial, we will use /srv/nfs.

sudo mkdir -p /srv/nfs

Create a test file so that you can verify access from the client:

echo "Hello from Ubuntu NFS Server" | sudo tee /srv/nfs/test.txt
Permissions matter: NFS does not replace normal Linux filesystem permissions. The ownership and mode of /srv/nfs determine what authenticated users can actually do after the export has been allowed by NFS.

Step 3: Configure /etc/exports

The /etc/exports file defines the directories exported by the NFS server and the clients or networks allowed to access them.

Open the file:

sudo nano /etc/exports

Add an entry similar to the following:

/srv/nfs 192.168.1.0/24(rw,sync,no_subtree_check)

In this example, clients on the 192.168.1.0/24 network are allowed read/write access.

Understanding the NFS Export Options

Option Purpose
rw Allows clients to read and write data.
ro Exports the directory as read-only.
sync Requests synchronous writes and is a common conservative choice for shared data.
no_subtree_check Disables subtree checking for the export.
root_squash Maps remote root access to an anonymous identity rather than granting remote root the same root privileges on the server.
Security recommendation: Do not use no_root_squash simply to make permissions problems disappear. It can grant remote root users powerful access to files on the NFS server. Use it only when a specific, understood requirement justifies it.

Step 4: Apply and Verify NFS Exports

After modifying /etc/exports, reload the export configuration with:

sudo exportfs -ra

The -r option re-exports directories, while -a applies the operation to all exports.

Verify the active exports:

sudo exportfs -v

You should see the exported directory together with the configured client restrictions and options.

Step 5: Configure the Ubuntu Firewall for NFS

If a firewall is active on the NFS server, allow NFS traffic from the client network rather than opening the service broadly to untrusted networks.

For an NFSv4-focused deployment, TCP port 2049 is the important NFS service port. Ubuntu’s documentation also notes that NFS-related services and configuration can vary depending on the Ubuntu release and NFS setup.

With UFW, an example restricted rule is:

sudo ufw allow from 192.168.1.0/24 to any port 2049 proto tcp

Check the resulting firewall configuration:

sudo ufw status
Firewall note: If you are using NFSv3 or additional RPC-based services, the firewall requirements can be different. This tutorial focuses on the modern NFS setup used for the basic Ubuntu server/client workflow.

Step 6: Install the NFS Client on Ubuntu

Move to the Ubuntu client machine and install nfs-common.

sudo apt update
sudo apt install nfs-common

The package provides the client-side NFS utilities required to mount network filesystems.

Step 7: Mount the Ubuntu NFS Share

Create a mount point on the client:

sudo mkdir -p /mnt/nfs

Mount the server’s exported directory:

sudo mount 192.168.1.10:/srv/nfs /mnt/nfs

Verify the mounted filesystem:

df -h /mnt/nfs

Then list its contents:

ls -la /mnt/nfs

You should see the test.txt file created earlier on the server.

Test Write Access

If the export and filesystem permissions allow writing, test the connection from the client:

echo "Created from NFS client" | sudo tee /mnt/nfs/client-test.txt

Check the server’s /srv/nfs directory to confirm the file has been created.

Step 8: Make the NFS Mount Persistent with /etc/fstab

A manually mounted NFS filesystem normally needs to be mounted again after a reboot. You can configure a persistent mount through /etc/fstab.

Open the client configuration:

sudo nano /etc/fstab

Add:

192.168.1.10:/srv/nfs /mnt/nfs nfs defaults,_netdev 0 0

Why Use _netdev?

The _netdev option identifies the filesystem as network-dependent. This helps the system treat the mount as dependent on network availability.

After editing /etc/fstab, reload systemd’s configuration:

sudo systemctl daemon-reload

Test the configuration without rebooting:

sudo umount /mnt/nfs
sudo mount -a
df -h /mnt/nfs
Always test /etc/fstab: A syntax error in /etc/fstab can affect system mounting behavior. Testing with mount -a before rebooting gives you an opportunity to identify problems.

Understanding Ubuntu NFS Permissions

One of the most common sources of confusion with NFS is the difference between an NFS export permission and the Linux filesystem permission.

An export can permit a client to access a directory with read/write privileges, but the underlying Unix ownership and mode bits still affect what users can actually do.

Layer Example What It Controls
NFS Export rw Whether the authorized NFS client can perform read/write operations through the export.
Linux Ownership user:group Which Unix user and group own files and directories.
Linux Permissions 755, 775, etc. Read, write and execute permissions for owner, group and others.
Identity Mapping UID/GID How user and group identities are interpreted between systems.
Enterprise environments: If users have different UID/GID values on different systems, permissions can behave unexpectedly. Centralized identity services or consistent identity management may be appropriate for larger environments.

Ubuntu NFS Security Best Practices

NFS should normally be deployed on a trusted network or protected network segment. Do not treat NFS as an Internet-facing file-sharing protocol.

  • Restrict exports to specific clients or trusted subnets.
  • Use a firewall to limit NFS traffic.
  • Avoid exporting sensitive system directories.
  • Keep normal Linux filesystem permissions enabled.
  • Use root_squash rather than disabling root squashing without a specific reason.
  • Use stable DNS names or static/reserved IP addresses for infrastructure systems.
  • Keep Ubuntu and NFS packages updated.
  • For environments requiring stronger authentication or encrypted NFS traffic, evaluate NFS with Kerberos.

Ubuntu’s current server documentation describes Kerberos-backed NFS configurations using security modes such as krb5, krb5i and krb5p, with krb5p providing authentication, integrity and privacy protection.

Troubleshooting Ubuntu NFS

1. Permission Denied

If the client receives a permission error, check both the export and the filesystem permissions.

sudo exportfs -v
ls -ld /srv/nfs

Confirm that the client’s address is allowed by /etc/exports and reapply the export:

sudo exportfs -ra

2. NFS Mount Hangs or Times Out

First test basic network connectivity:

ping 192.168.1.10

Then verify that the NFS service is running on the server:

sudo systemctl status nfs-server

Also check firewall rules and confirm that TCP port 2049 is reachable from the client when using the NFSv4 workflow described here.

3. The Export Does Not Appear

On the server, inspect the active exports:

sudo exportfs -v

Re-read the export configuration:

sudo exportfs -ra

4. Mount Point Problems

Make sure the client mount directory exists and is not being used as a location for important local files.

sudo mkdir -p /mnt/nfs
ls -la /mnt/nfs

5. fstab Mount Fails After Reboot

Test the entry manually:

sudo umount /mnt/nfs
sudo mount -a

If the command returns an error, correct the /etc/fstab entry before rebooting.

Useful Ubuntu NFS Diagnostic Commands

Command Purpose Run On
systemctl status nfs-server Check the NFS server service. Server
exportfs -v Display active NFS exports. Server
exportfs -ra Reapply export configuration. Server
showmount -e SERVER_IP Query exported filesystems where supported by the server/client setup. Client
mount | grep nfs Display currently mounted NFS filesystems. Client
df -h Display mounted filesystem capacity. Client
nfsstat -c Display NFS client statistics. Client
nfsstat -s Display NFS server statistics. Server

Build an Ubuntu and Linux Infrastructure Knowledge Cluster

This NFS tutorial can serve as part of a broader VMoreCloud Ubuntu and Linux infrastructure topic cluster. Continue with related storage, networking, firewall and Ubuntu Server guides.

Ubuntu NFS Deployment Best Practices

For Home Labs

  • Use a dedicated private subnet.
  • Assign a stable IP to the NFS server.
  • Export only the required directories.
  • Use UFW or another firewall.
  • Back up important shared data.

For Production

  • Use dedicated storage and monitoring.
  • Restrict exports to required clients.
  • Use centralized identity management where appropriate.
  • Evaluate Kerberos for stronger NFS security.
  • Monitor capacity, latency and NFS errors.

Frequently Asked Questions

What is NFS in Ubuntu?

NFS, or Network File System, allows an Ubuntu server to share directories over a network so authorized clients can mount and access those directories as part of their local filesystem.

Which package installs the Ubuntu NFS server?

The standard Ubuntu NFS server package is nfs-kernel-server.

Which package is required on an Ubuntu NFS client?

Ubuntu clients use the nfs-common package for NFS client functionality.

Where is the Ubuntu NFS export configuration stored?

The primary export configuration is stored in /etc/exports. After changing it, use exportfs -ra to apply the export configuration.

How do I permanently mount an NFS share in Ubuntu?

Add the NFS server path, mount point and filesystem type to /etc/fstab. Using _netdev identifies the filesystem as network-dependent.

Is NFS encrypted by default?

Standard NFS deployments do not automatically provide encrypted application data simply because NFS is being used. For environments requiring stronger authentication, integrity and privacy protections, Ubuntu supports Kerberos-based NFS security configurations.

Can Windows access an Ubuntu NFS share?

Windows versions and editions have varied in their NFS client/server capabilities. If the primary clients are Windows systems, SMB is often the more natural file-sharing protocol. For Linux-to-Linux infrastructure, NFS is a common choice.

Conclusion

Setting up an Ubuntu Network File System (NFS) provides a straightforward way to centralize shared Linux storage and make it available to authorized systems across a network.

The basic workflow is:

  1. Install nfs-kernel-server on the Ubuntu server.
  2. Create the directory that will be shared.
  3. Define authorized clients in /etc/exports.
  4. Apply the configuration with exportfs.
  5. Install nfs-common on the client.
  6. Create a client-side mount point.
  7. Mount the NFS export.
  8. Use /etc/fstab for persistent mounts.
  9. Restrict access with firewall and export rules.

For a small Linux lab, this setup can provide a useful centralized storage layer. In larger environments, combine NFS with appropriate storage architecture, identity management, monitoring, backups and security controls.

Build Your Ubuntu Infrastructure with VMoreCloud

Continue exploring practical Ubuntu Server, Linux networking, storage, virtualization and infrastructure administration guides from VMoreCloud.

Explore More Linux & Cloud Guides

References & Sources

About the Author

Khurram Shahzad — Hybrid Cloud & Virtualization Engineer

Hybrid Cloud & Virtualization Engineer specializing in VMware, Azure, AWS, Windows Server, Microsoft 365, Linux, networking, backup & disaster recovery. I share practical guides, technical projects and insights into modern IT infrastructure through VMoreCloud.

Technical Disclaimer: Commands and configuration examples in this guide are intended for educational and infrastructure-lab purposes. Replace example IP addresses, hostnames, paths and permissions with values appropriate for your environment. Test filesystem, export and firewall changes before deploying them to production systems.
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO