Cannot Specify Fixed Ports for mountd and statd

Bug #1971096 reported by Granville Xiong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nfs-utils (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

=== Release Version ===

Ubuntu 22.04

=== Package Version ===

nfs-utils 1:2.6.1-1ubuntu1

=== Custom Settings ===

In order to use NFSv3 client (e.g. on Windows 10) to mount the directories exported by the NFS server behind a firewall, I need to specify fixed ports to be used by /usr/sbin/rpc.mountd and /usr/sbin/rpc.statd. This was done by the following steps:

In /etc/default/nfs-kernel-server:
RPCMOUNTDOPTS="--manage-gids --port 32767"
RPCNFSDOPTS="--nfs-version 3,4"

In /etc/default/nfs-common:
STATDOPTS="--port 32766 --outgoing-port 32765"

Then I restarted NFS server:
systemctl restart nfs-kernel-server

=== Expected Results ===

The output of "rpcinfo -p" should show something similar to the following messages:

   program vers proto port service
    100000 4 tcp 111 portmapper
    100000 3 tcp 111 portmapper
    100000 2 tcp 111 portmapper
    100000 4 udp 111 portmapper
    100000 3 udp 111 portmapper
    100000 2 udp 111 portmapper
    100005 1 udp 32767 mountd
    100005 1 tcp 32767 mountd
    100005 2 udp 32767 mountd
    100005 2 tcp 32767 mountd
    100005 3 udp 32767 mountd
    100005 3 tcp 32767 mountd
    100024 1 udp 32766 status
    100024 1 tcp 32766 status
    100003 3 tcp 2049 nfs
    100003 4 tcp 2049 nfs
    100227 3 tcp 2049
    100003 3 udp 2049 nfs
    100227 3 udp 2049
    100021 1 udp 32768 nlockmgr
    100021 3 udp 32768 nlockmgr
    100021 4 udp 32768 nlockmgr
    100021 1 tcp 32768 nlockmgr
    100021 3 tcp 32768 nlockmgr
    100021 4 tcp 32768 nlockmgr
    150001 1 udp 835 pcnfsd
    150001 2 udp 835 pcnfsd
    150001 1 tcp 836 pcnfsd
    150001 2 tcp 836 pcnfsd

Above messages are the output of the NFS server on Ubuntu 20.04 which shows the desired ports are used to mountd and statd daemons.

Actual results:

However, the actual output of "rpcinfo -p" on Ubuntu 22.04 shows the following:

   program vers proto port service
    100000 4 tcp 111 portmapper
    100000 3 tcp 111 portmapper
    100000 2 tcp 111 portmapper
    100000 4 udp 111 portmapper
    100000 3 udp 111 portmapper
    100000 2 udp 111 portmapper
    100024 1 udp 33937 status
    100024 1 tcp 60673 status
    100005 1 udp 43042 mountd
    100005 1 tcp 60125 mountd
    100005 2 udp 48157 mountd
    100005 2 tcp 39195 mountd
    100005 3 udp 50182 mountd
    100005 3 tcp 57251 mountd
    100003 3 tcp 2049 nfs
    100003 4 tcp 2049 nfs
    100227 3 tcp 2049
    100021 1 udp 32768 nlockmgr
    100021 3 udp 32768 nlockmgr
    100021 4 udp 32768 nlockmgr
    100021 1 tcp 32768 nlockmgr
    100021 3 tcp 32768 nlockmgr
    100021 4 tcp 32768 nlockmgr

Obvisouly, the ports used by mountd and statd are different from the specified values. Moreover, after each restart, the ports numbers also change. This means that random ports are assigned.

=== Possible Causes ===

I checked out the systemd configuration files in use and found the following clues:

/lib/systemd/system/nfs-kernel-server.service:
In 20.04: ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS
In 22.04: ExecStart=/usr/sbin/rpc.nfsd

/lib/systemd/system/nfs-mountd.service:
In 20.04: ExecStart=/usr/sbin/rpc.mountd $RPCMOUNTDARGS
In 22.04: ExecStart=/usr/sbin/rpc.mountd

/lib/systemd/system/nfs-kernel-server.service:
In 20.04: ExecStart=/sbin/rpc.statd --no-notify $STATDARGS
In 22.04: ExecStart=/sbin/rpc.statd

So, I think above differences could possibly explain why fixed ports can be specified for the NFS server in 20.04 but not in 22.04.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Hi,

the /etc/default/nfs-* files are ignored by the NFS server or client in Ubuntu 22.04. They were left there as a precaution because of the conversion process that converts those options into the new /etc/nfs.conf and /etc/nfs.conf.d/local.conf files. I do agree it causes confusion, and the /etc/default/nfs-* files should either be removed, or have some text explaining that they are there just for old sysvinit compatibility. This may change in a future update.

You should look into /etc/nfs.conf to set these options. There is also a nfs.conf manpage you can review, and the ubuntu server guide was updated regarding this change:

https://ubuntu.com/server/docs/service-nfs

Changed in nfs-utils (Ubuntu):
status: New → Invalid
Revision history for this message
Granville Xiong (g4x86) wrote :

Thanks a lot for the updates! With the information provided, I updated the configuration settings in /etc/nfs.conf and /etc/nfs.conf.d and then NFS server works as expected. And yes it's a good idea to put some notes in the obsolete configuration files, so that users can be instructed for the changes in the new release.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I filed bug #1973630 about dropping the old config files, or adding a remark to them.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.