Monday, July 31, 2017

Re: permission denied local nfs mount

On Fri, Jul 28, 2017 at 7:36 PM, Allan Streib <astreib@indiana.edu> wrote:
> $ cat /etc/exports
> /home/astreib/work/new-site.org -ro -network=127.0.0.1
>
> Everyhing works if I remove the "-network=" from /etc/exports, i.e.:
>
> /home/astreib/work/new-site.org -ro 127.0.0.1
>
> I don't really understand why?

If you don't specify -network, then 127.0.0.1 is treated as the
address (or name) of a specific host. Since you are going to be
mounting this via 127.0.0.1, that counts as a host address and
everything works.

If you do specify -network, then 127.0.0.1 is treated as a network
number, and the default netmask would be 255.0.0.0. I don't know why
that's not working, but (a) I always specify -mask whenever I use
-network, and (b) I always ensure that the host portion of the network
number is all zeros. So if I were to do it I would use:

/home/astreib/work/new-site.org -ro -network 127.0.0.0 -mask 255.0.0.0

(I would use 255.0.0.0 as the mask simply because that's the mask the
actual loopback interface is using, but I don't think it actually
matters as far as /etc/exports is concerned -- if you want to use an
unusual mask to allow access to a subset of a network then as far as I
know you should be able to).

Unless you are binding multiple addresses on your loopback interface,
I would just use 127.0.0.1 without -network or -mask and be done with
it. Why open up the mount to an entire network when you really just
need to open it up to a single host (yourself)?

This is what I do in a similar situation (serving both ftpd and httpd
from the same directory):

relevant line from /etc/exports:
/nfs/archive/dist/OpenBSD -maproot=root -ro 127.0.0.1

relevant line from /etc/fstab:
localhost:/nfs/archive/dist/OpenBSD /var/www/ftp/pub/OpenBSD nfs
ro,nodev,nosuid 0 0

Works fine for me.

-ken

No comments:

Post a Comment