The cart is empty

Encountering the "mount.NFS: Connection timed out" error while attempting to connect to an NFS server on CentOS 7 indicates that the client is unable to establish a connection with the NFS server, which could be due to several different issues. In this article, we'll delve into the steps to diagnose and resolve this problem in detail.

Prerequisites

Before attempting to resolve the issue, ensure that:

  • You have root access or sudo access on the CentOS 7 system.
  • You know the IP address or hostname of the NFS server you're trying to connect to.
  • The NFS server is properly configured and running.

Step 1: Check NFS Server Availability

The first step is to verify that the NFS server is available and running. You can do this by using the ping command to check server availability and showmount -e [server_ip] to confirm that the server is properly exporting shares.

ping -c 4 [server_ip]
showmount -e [server_ip]

Step 2: Check Firewall and Network Rules

Connection issues might be caused by firewall settings on either the client or the server. Ensure that firewall rules on both sides allow communication over ports used by NFS (e.g., port 2049 for NFSv4).

On CentOS 7, you can use firewall-cmd to add an exception for NFS:

sudo firewall-cmd --zone=public --add-service=nfs --permanent
sudo firewall-cmd --reload

Step 3: Check NFS Services on the Client

Make sure that all necessary NFS client services are running. This includes rpcbind and nfs-client.target.

sudo systemctl start rpcbind
sudo systemctl enable rpcbind
sudo systemctl start nfs-client.target
sudo systemctl enable nfs-client.target

Step 4: Resolve MTU Issues

Mismatched Maximum Transmission Units (MTU) between the client, server, and the network devices in between can cause connection problems. Check and, if necessary, standardize the MTU settings on all devices.

Step 5: Entries in /etc/hosts

Ensure that the /etc/hosts file on the client correctly maps the server's hostname to its IP address. This can help in case of name resolution issues.

Step 6: Use Proper Mount Options

When mounting NFS shares, make sure you're using the correct mount options. For example:

sudo mount -t nfs [server_ip]:/path/to/share /local/mount/point -o rw,timeo=600,retrans=2

This command sets timeout and retransmission counts, which can help in case of unstable network connections.

 

If you still encounter the "mount.nfs: Connection timed out" error even after performing the above steps, further network connection diagnostics using tools like tcpdump or consulting with your network administrator may be necessary. Always ensure that your systems are up-to-date with the latest versions to avoid known bugs and vulnerabilities.