Getting access denied error while mounting nfs share


#1

Hi
I am finding this error while trying to mount nfs share in client side. These are two virtual machine made for testing purpose.

nfs server name- server1.example.com
nfs client name- client.example.com

In nfs server - [root@server1 ~]# cat /etc/exports
/nfs *.example.com(rw,sync,no_root_squash)

In nfs client- [root@client ~]# showmount -e server1.example.com
Export list for server1.example.com:
/nfs *.example.com

[root@client ~]# mount server1.example.com:/nfs /mnt
mount.nfs: access denied by server while mounting server1.example.com:/nfs

Firewall is temporarily disabled in server and client. Selinux has been set to permissive in server and client.

So friends please guide me. Thanks in advance

Regards
Jagamohan


#2

@Jagamohan_Mohapatra

Are you able to ping to the client server using hostname, ip and hostname should be resolved and also once trey the below command

#mount -t nfs -o nfsvers=3 server.example.com:/share /mnt/nfs

for troubleshooting use -vv

#mount -t nfs -vvvv server.example.com:/share /mnt/nfs

#3

@Jagamohan_Mohapatra

  • Try using in “/etc/exports” as

/nfs client.example.com(rw,sync,no_root_squash)

give specific IP of Client Machine in “/etc/exports” it will work

Thanks!!!


#4

Hi Raghuu

Please find below output . Client is able to ping using hostname. Still same error.

[root@client ~]# mount -t nfs -o nfsvers=3 server1.example.com:/nfs /mnt/nfs
mount.nfs: access denied by server while mounting server1.example.com:/nfs
[root@client ~]# mount -t nfs -vvvv server.example.com:/nfs /mnt/nfs
mount.nfs: timeout set for Tue Aug 30 17:22:48 2016
mount.nfs: trying text-based options ‘vers=4,addr=192.168.0.2,clientaddr=192.168.100.209’
mount.nfs: mount(2): Network is unreachable
mount.nfs: Network is unreachable
[root@client ~]# ping server1.example.com
PING server1.example.com (192.168.100.156) 56(84) bytes of data.
64 bytes from server1.example.com (192.168.100.156): icmp_seq=1 ttl=64 time=0.651 ms
64 bytes from server1.example.com (192.168.100.156): icmp_seq=2 ttl=64 time=0.779 ms
64 bytes from server1.example.com (192.168.100.156): icmp_seq=3 ttl=64 time=0.317 ms
64 bytes from server1.example.com (192.168.100.156): icmp_seq=4 ttl=64 time=1.02 ms
^C
server1.example.com ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3001ms
rtt min/avg/max/mdev = 0.317/0.692/1.021/0.254 ms

But now I am able mount using IP
[root@client ~]# mount -t nfs -o nfsvers=3 192.168.100.156:/nfs /mnt/nfs
[root@client ~]# cd /mnt/nfs
[root@client nfs]# ls
file1
[root@client nfs]#

Could you please explain why I am not able mount using hostname which I am able to ping. Please find /etc/export for reference.

[root@server1 ~]# cat /etc/exports
/nfs 192.168.100.209(rw,sync,no_root_squash)
/nfs *.example.com(rw,sync,no_root_squash)
[root@server1 ~]#

Regards
Jagamohan


#5

once kindly check the hostname and also once share the content of /etc/hosts form both the servers client and server and also once check the SELinux whether it is enabled or disabled

#vim /etc/sysconfig/selinux

SELINUX=disabled

and also once check the log messages from client

and also verify that the portmap service is running.


#6

Thanks Raghuu
Your solution worked.

Regards
Jagamohan


#7

Hiii
I hope you have got a solution to your problem.
though I am a bit late to reply nut would like to add to the solution for the why actually you are not able to mount or ping using hostname .I think you should mention the ip and the hostname in /etc/hosts.For eg: 192.168.5.11 server1.example.com.