在 Ubuntu 20.x 服务器上为 NFS v3 设置静态端口

在 Ubuntu 20.x 服务器上为 NFS v3 设置静态端口

我正在尝试在 Ubuntu 20.x Server 上使用 NFSv3,并且需要设置静态端口才能使用 UFW。不幸的是,需要连接到此服务器的 Windows 10 仅支持 NFSv3,因此仅保持端口 2049 开放是不够的。

我曾尝试将端口添加到 /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

尽管该配置确实需要 64 台服务器来启动,但即使在重新启动后,它也没有拾取底部的端口配置。

有人知道我可以在哪里正确设置这些吗?

答案1

我想通了,对于静态端口,需要编辑这些文件:

用于 MOUNTD 的 /etc/default/nfs-kernel-server:

原来的:

RPCMOUNTDOPTS="--manage-gids"

新的:

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

/etc/default/nfs-common 用于 STATD:

原来的:

STATDOPTS=

新的:

STATDOPTS="--port 662"

/etc/default/quotas 用于配额 我决定不为这个项目设置配额。但是,它应该是:

RPCRQUOTADOPTS="-p 875"

LOCKD 的 /etc/sysctl.conf:

添加:

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

然后运行:

sysctl -p
systemctl restart nfs-kernel-server

相关内容