We would like to move away from sshfs
to nfs
.
The last thing holding us back is the fact that rpcbind
(which I assume is required for nfs
to work) does not allow you to specify the TCP
(not UDP
) IP that it binds to.
There is the -h
flag, but this is only for the UDP ports it opens up. this does not affect the TCP ports, they still open on 0.0.0.0:...
Does anyone know how we can secure rpcbind
by not exposing it to our public interface?
Or even better, is there a way to use nfs
without rpcbind
?
Thanks!
The rpcbind is required to map RPC service to network ( read TCP or UDP ) address and port. NFS versions 2 and 3 require an additional service mountd to allow clients to get initial file handle. While nfs has a well know port number 2049, mountd doesn't. IOW, if you want to use NFSv3 you will need to run rpcbind as well (well, there are probably some mount options to tell where mound is running). In opposite to v3, NFSv4 requires only single port 2049 and does not need mountd at all. This makes rpcbind free NFS setup possible. Just be aware, that some (old) clients may still try to talk to rpcbind even for v4.
Now, about rpcbind. Why you want to protect it? If it's not available to clients, then they cant mount? The only reason to protect is to limit number of clients which can do updates. But this is already in place as rpcbind uses unix domain socket and disallow any remote client perform updates. Even on a local host you need to be root for that. If you want to protect from some clients only, then iptables is your friend (or what ever firewall your OS has):
The lookup for the service port is baked into the RPC protocol, so you'd have to do something quite exotic to avoid rpcbind when running NFS.
You could block connections from particular addresses or interfaces using iptables; with tcpwrappers (/etc/hosts.allow, /etc/hosts.deny); or - for the adventurous - with SELinux.
tcpwrappers is available natively if "ldd /sbin/rpcbind" shows a link to libwrap, otherwise you'd need to suppress the usual startup and instead run it out of inetd/xinetd through tcpd. I haven't tried that myself.
For anyone looking for answer in 2019, no need to add firewall rules.
rpcbind
takes-h IP
option. It's enough to add it to/etc/sysconfig/rpcbind
(Red Hat, Fedora, SLES, openSUSE) or/etc/default/rpcbind
(Debian, Ubuntu).No need to set up firewall rules anymore. With recents Linux distribution where /etc/hosts.deny/allow are available, you can simply do the following:
(Assuming 10.0.0.0/16 is your private network).
Recents versions of NFS uses rpcbind, but older uses portmap, so it will depends on your OS.