Search This Blog

mount.nfs: mount to NFS server failed: System Error: No route to host.

When enabling NFS service on a Cent OS Linux server, the client could not mount the NFS shares on the server. Got the error below:
mount.nfs: mount to NFS server failed: System Error: No route to host.

The reason is: the iptables firewall blocks the NFS service ports. (NOTE: by default, iptables firewall is enabled on Redhat like Linux, e.g. CentOS, Fedora).

To allow the NFS service ports:

  1. Edit /etc/sysconfig/nfs and uncomment/add the following lines:
    LOCKD_TCPPORT=32803
    LOCKD_UDPPORT=32769
    MOUNTD_PORT=892
    STATD_PORT=662
    STATD_OUTGOING_PORT=2020
    
  2. Restart the nfs services:
    sudo /etc/init.d/nfs restart
    sudo /etc/init.d/nfslock restart
    
  3. check if the ports are open as expected:
    rpcinfo -p localhost
       program vers proto   port  service
        100000    4   tcp    111  portmapper
        100000    3   tcp    111  portmapper
        100000    2   tcp    111  portmapper
        100000    4   udp    111  portmapper
        100000    3   udp    111  portmapper
        100000    2   udp    111  portmapper
        100021    1   udp  32769  nlockmgr
        100021    3   udp  32769  nlockmgr
        100021    4   udp  32769  nlockmgr
        100021    1   tcp  32803  nlockmgr
        100021    3   tcp  32803  nlockmgr
        100021    4   tcp  32803  nlockmgr
        100011    1   udp    875  rquotad
        100011    2   udp    875  rquotad
        100011    1   tcp    875  rquotad
        100011    2   tcp    875  rquotad
        100003    2   tcp   2049  nfs
        100003    3   tcp   2049  nfs
        100003    4   tcp   2049  nfs
        100227    2   tcp   2049  nfs_acl
        100227    3   tcp   2049  nfs_acl
        100003    2   udp   2049  nfs
        100003    3   udp   2049  nfs
        100003    4   udp   2049  nfs
        100227    2   udp   2049  nfs_acl
        100227    3   udp   2049  nfs_acl
        100005    1   udp    892  mountd
        100005    1   tcp    892  mountd
        100005    2   udp    892  mountd
        100005    2   tcp    892  mountd
        100005    3   udp    892  mountd
        100005    3   tcp    892  mountd
        100024    1   udp    662  status
        100024    1   tcp    662  status
    
  4. edit /etc/sysconfig/iptables and add the following rules:
    -A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT
    
  5. Restart iptables:
    sudo service iptables restart

Now you can mount the NFS server on the client side.

Note:

The above solution is for the Redhat Like Linux (RHEL, CentOS, Fedora).

See Also:





No comments:

Post a Comment