1. Verify NFS Server Installation

Ensure that the NFS server packages are installed on your server:

sudo apt update
sudo apt install nfs-kernel-server

2. Configure NFS Exports

Ensure your /etc/exports file is correctly configured. Your entry should look like this:

/data/nfs/kubedata  *(rw,sync,no_subtree_check)

3. Apply Export Changes

After editing /etc/exports, you need to apply the changes:

sudo exportfs -ra

4. Check NFS Server Status

Ensure the NFS server is running:

sudo systemctl status nfs-server

If it’s not running, start it:

sudo systemctl start nfs-server

And enable it to start on boot:

sudo systemctl enable nfs-server

5. Configure Firewall

Ensure that your firewall allows NFS traffic. You need to open the following ports for NFS:

  • 111 (rpcbind/sunrpc)
  • 2049 (nfs)
  • 20048 (mountd, if used)

Using ufw:

sudo ufw allow 111
sudo ufw allow 2049
sudo ufw allow 20048
sudo ufw reload

Using iptables:

sudo iptables -A INPUT -p tcp --dport 111 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 111 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 2049 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 2049 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 20048 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 20048 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4

6. Check Network Configuration

Ensure that there are no network issues preventing access:

  • Verify that the server and client can ping each other.
  • Check for any network policies or firewalls that might be blocking the traffic.

7. Client Configuration

On the client side, ensure the NFS client package is installed:

sudo apt update
sudo apt install nfs-common

Then, try to mount the NFS share:

sudo mount -t nfs <server-ip>:/data/nfs/kubedata /mnt

Replace <server-ip> with the actual IP address of your NFS server.

8. Verify Mount

Check if the NFS share is mounted correctly:

df -h /mnt

9. Troubleshooting

If you still face issues, check the following logs for errors:

  • On the server: /var/log/syslog or /var/log/messages
  • On the client: /var/log/syslog or /var/log/messages

Summary

  1. Verify NFS server installation.
  2. Correctly configure /etc/exports.
  3. Apply export changes.
  4. Ensure NFS server is running.
  5. Open necessary firewall ports.
  6. Check network connectivity.
  7. Ensure NFS client installation and configuration.
  8. Attempt to mount the NFS share from the client.
  9. Check logs for errors if issues persist.

By following these steps, you should be able to diagnose and resolve the issue preventing access to your NFS share.

Example Mount Commands

sudo mount -t nfs 131.234.29.22:/data/nfs/kubedata /mnt/kubedata
sudo mount -t nfs 131.234.29.22:/data/nfs/module /mnt/module