27

On my Ubuntu system, I have this line in /etc/fstab:

myserver:/home/me /mnt/me nfs rsize=8192,wsize=8192,timeo=14,intr

When I do

sudo mount -a

I get:

mount.nfs: access denied by server while mounting myserver:/home/me

How can I diagnose this problem? The nfs server is also Ubuntu.

Additional details: I am able to mount this nfs share from other Ubuntu clients on the same network with no problem. However, the problematic client is different in that it is running inside VirtualBox on a Windows system. I can ping "myserver" fine from the problematic client.

EDIT: /etc/exports on "myserver":

/home/me *(rw,all_squash,async,no_subtree_check,anonuid=1000,anongid=1000)

/etc/hosts.allow and /etc/hosts.deny on "myserver" are both all comments. And keep in mind, that I can connect fine from other clients on the same network.

3
  • have you tried tailing the log files on the remote ubuntu nfs server? See if an attempt is being made to nfs mount from the virtual machine on the windows box.
    – Patrick R
    Commented Jan 29, 2010 at 14:47
  • which log files exactly?
    – JoelFan
    Commented Jan 29, 2010 at 15:39
  • Is anything showing up in /var/log/messages? Commented Jan 29, 2010 at 16:35

7 Answers 7

45

Found it!

One of the logs had the line:

refused mount request from 192.168.1.108 for /home/me (/home/me): illegal port 64112

I googled and found that since the port is over 1024 I needed to add the "insecure" option to the relevant line in /etc/exports on the server. Once I did that (and ran exportfs -r), the mount -a on the client worked.

5
  • 5
    While that works, now any non-root user can pretend to be a new instance of NFS and have access to all your files. Does anyone know if theres a way to just get the nfs client to stop using these high port numbers?
    – semi
    Commented Mar 5, 2011 at 1:10
  • Thanks so much for this, saved my ass. Was ready to give up after HOURS of googling. I didn't see it in the logs because I was grepping for "nfs", but this is actually logged my "mountd".
    – Cory J
    Commented Aug 2, 2011 at 5:47
  • 1
    @Cory J, thanks for taking the time to let me know it helped! Your comment made me take another look at this question and I see it has over 12K views! So probably it helped other people to but you are the only one that said "thanks"! :)
    – JoelFan
    Commented Aug 2, 2011 at 14:50
  • 2
    For future visitors: 1) The illegal port 64112 message can be found on NFS server /var/log/messages 2) The insecure is added like /path IP(rw,no_root_squash,no_all_squash,sync,insecure).
    – dibery
    Commented Jan 22, 2021 at 6:40
  • Saved me. My setup: Server in Ubuntu20.04 with static ip inside a virtual box with bridged net running on a Win10 Pro host machine. Client in Ubuntu20.04 running in a docker container with --privileged on top of a WSL2-based Ubuntu20.04 on the very same Win10 Pro host machine. Adding the insecure allowed the docker container mount the virtual box server. Thanks! Struggling for 48h now. Resolved! Commented Apr 26, 2021 at 18:27
19

This question is related on how the network is set for your vm.

By default with VirtualBox, you have NAT network. Which result in port translation.

Step by step this gives :

  1. The NFS client is using a reserved port (<1024 ... that can only be opened by root -> secured)
  2. Virtualbox does the port translation (NAT) -> client port is now greater than 1024
  3. The NFS server refuses the connection for that insecure port.

As mentioned by @JoelFan, one fix would be to set the insecure option to the server. This is a quick fix but ... insecure ;)

What fixed the case for me (in a secured manner) was to change from NAT to Bridge network for this vm. This way, my vm has it's own IP address and no port translation is done.

3

Guess what... for me, the source of exactly the same error was a version mismatch between my NFS client and the server.

The logs were silent as if nothing happened, and only nfswatch running on the server side helped me clarify the situation.

The problem was resolved by adding the nfsver mount option on the client side:

server:/path   /mount/point   nfs   nfsvers=3   0 0
1
  • This was also my problem. Debian 6 (Squeeze) with mount package v2.17.2-9 installed. Solution worked. Commented Jul 25, 2014 at 8:58
3

I had the exact same issue recently, posted here: NFS Illegal Port

If you do not want to use the insecure option or do not have the luxury of using a "Bridge" network for your VM, you can simply add an outbound NAT for your local LAN network/single host.

I solved this by setting up a NAT outbound rule on my OPNSense firewall, for my entire local LAN network with the Static Port setting enabled, which prevents the firewall from changing the ports when sending out the traffic, as explained here: OPNsense Documentation

1

Have you verified that the name resolution is correct on the server for the client that is trying to connect (and is listed in the exports file)?

1
  • see my edits in the question... I am allowing all
    – JoelFan
    Commented Jan 29, 2010 at 15:56
0

check the files hosts.allow and hosts.deny and whether the client is entered correctly. when this does not help, please post your export file.

1
  • see my edits in the question
    – JoelFan
    Commented Jan 29, 2010 at 15:59
0

In case this helps other people, I have a Synology NAS and the NFS point actually added another item to the path.

I was trying to mount "xxx.xxx.xxx.xxx/folder" as this is what I do in Windows. But for Ubuntu with NFS I had to use "xxx.xxx.xxx.xxx/volume1/folder".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .