NFS: Hide shares

The network shares ("exports") available on a NFS server can be listed with showmount -e myserver. It will list all exported directories, even if the client is not allowed to mount all of them.

This here is a workaround. A real solution - hiding all exports that the client does not have access to, but showing the rest - does not exist to my knowledge.

With NFS v4 it is possible to limit listing the shares to select clients only: By restricting access to rpc.mountd via /etc/hosts.allow:

/etc/hosts.allow
mountd: client1 client2

This will allow client1 and client2 to list the shares:

root@client1:~> showmount -e myserver
Export list for myserver:
/data/media          client1,client2
/data/backup         client1,client2,client3

On client3 it will lead to an error:

root@client3:~> showmount -e myserver
rpc mount export: RPC: Authentication error; why = Failed (unspecified error)

The downside is that NFS v2 and v3 mounts will not work anymore, because a mount command in this versions needs to contact rpc.mountd.

Written by Christian Weiske.

Comments? Please send an e-mail.