4

I'm trying to use NFSv3 on Ubuntu 20.x Server and need to set static ports to use UFW. Unfortunately Windows 10 which needs to connect to this server only supports NFSv3 so leaving just port 2049 open is not enough.

I have tried to add ports to the /etc/default/nfs-kernel-server:

# Number of servers to start up
RPCNFSDCOUNT=64

Runtime priority of server (see nice(1))

RPCNFSDPRIORITY=0

Options for rpc.mountd.

If you have a port-based firewall, you might want to set up

a fixed port here using the --port option. For more information,

see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS

To disable NFSv4 on the server, specify '--no-nfs-version 4' here

RPCMOUNTDOPTS="--manage-gids"

Do you want to start the svcgssd daemon? It is only required for Kerberos

exports. Valid alternatives are "yes" and "no"; the default is "no".

NEED_SVCGSSD=""

Options for rpc.svcgssd.

RPCSVCGSSDOPTS=""

LOCKD_TCPPORT=32803 LOCKD_UDPPORT=32769 MOUNTD_PORT=892 STATD_PORT=662 RQUOTAD_PORT=875

While the config did take the 64 count of servers to spin up, it hasn't picked up the port configs at the bottom, even after a reboot.

Does anyone know where can I set these properly?

Dmitry
  • 81

1 Answers1

4

I figured this out, for static ports these files need to be edited:

/etc/default/nfs-kernel-server for MOUNTD:

Original:

RPCMOUNTDOPTS="--manage-gids"

New:

RPCMOUNTDOPTS="--manage-gids -p 892"

/etc/default/nfs-common for STATD:

Original:

STATDOPTS=

New:

STATDOPTS="--port 662"

/etc/default/quotas for Quotas I decided against running quotas for this project. However, it should be:

RPCRQUOTADOPTS="-p 875"

/etc/sysctl.conf for LOCKD:

Add:

fs.nfs.nlm_tcpport = 32803
fs.nfs.nlm_udpport = 32769

Then just run:

sysctl -p
systemctl restart nfs-kernel-server
Dmitry
  • 81
  • 1
    file path /etc/default/quotas likely should be /etc/default/quota – pangyuteng May 26 '22 at 19:55
  • 1
    for those needing to enable nfs v3, also ensure ufw have these ports open 2049 111 892 662 875 32803 32769 – pangyuteng May 26 '22 at 20:51
  • 2
    Great summary. Note: Be careful if using Ubuntu 22.04: All these options are now moved to /etc/nfs.conf. The old files are still there for some reason, but unused... Use "rpcinfo -p" to verify the result after configuring. See also https://ubuntu.com/server/docs/service-nfs – StellarVortex May 30 '23 at 09:30