Set Static Ports for NFS v3 on Ubuntu 20.x Server

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
# 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?

0

1 Answer

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 QuotasI 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
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like