Neither the configuration in /etc/nfs.conf
/ /etc/nfs.conf.d/*
nor the RPCNFSDOPTS
specified in /etc/default/nfs-kernel-server
affect the interfaces, on which rpc.mountd
will listen on. So none of the other answers here actually answer the original question, which was about restricting access to rpc.mountd
to a specific interface.
The man page of rpc.mountd
does NOT list an option, that performs the required restriction. Instead, it recommends to use either the tcp_wrapper
library or the kernel firewall iptables
for that purpose.
However, with most systems having migrated already to NFS protocol version 4, there is an easier solution: NFSv4 does not need rpc.mountd
anymore. An explanation how to do that can be found towards the bottom of this page: https://wiki.debian.org/NFSServerSetup
So, to restrict to NFS access to NFSv4 on a local interface, do the following on recent Ubuntu / Debian servers:
systemctl stop nfs-kernel-server.service
systemctl stop rpcbind.service
systemctl mask rpcbind.service
systemctl mask rpcbind.socket
vi /etc/default/nfs-common
NEED_STATD="no"
NEED_IDMAPD="yes"
vi /etc/default/nfs-kernel-server
RPCNFSDOPTS="-H YOUR-LOCAL-IP-YOU-WANT-TO-BIND-TO -N 2 -N 3"
RPCMOUNTDOPTS="--manage-gids -N 2 -N 3"
systemctl start nfs-kernel-server.service
Of the four configuration options listed here (NEED_STATD
, NEED_IDMAPD
, RPCNFSDOPTS
and RPCMOUNTDOPTS
) you will find only the last one already defined in the default versions of those files as shipped with Debian or Ubuntu. Make sure to edit RPCMOUNTDOPTS
apropriately and to add the other three. Of course, you may freely choose another editor instead of vi
.
Before masking rpcbind.service
with systemctl
(which pretends, that it is started, though it is not), make sure, that no other service on your machine needs that it.