NFS Server Configuration Issue with assinging static ports in ClearLinux

Okay, with a lot of testing I found one way to set this up on Clearlinux. All the other ways of other distributions did not work.

Step 1: Configure the rpc.statd Service

  • Open the NFS common (rpc-statd) service file:
sudo nano /usr/lib/systemd/system/rpc-statd.service
  • In this file, set the static ports for rpc.statd:
# Statd is not needed for NFSv4!
ExecStart=/usr/sbin/rpc.statd -p 12001 -o 12002

https://linux.die.net/man/8/rpc.statd

-o, --outgoing-port port
Specifies the source port number the sm-notify command should use when sending reboot notifications. See sm-notify(8) for details.
-p, --port port
Specifies the port number used for RPC listener sockets. If this option is not specified, rpc.statd chooses a random ephemeral port for each listener socket.
This option can be used to fix the port value of its listeners when SM_NOTIFY requests must traverse a firewall between clients and servers.

  • Save the changes and close the text editor.

Step 2: Configure the rpc.mountd Service

  • Open the NFS server (nfs-mountd.service) service file:
sudo nano /usr/lib/systemd/system/nfs-mountd.service
  • In this file, set the static port for rpc.mountd:
ExecStart=/usr/sbin/rpc.mountd -p 12000
  • Save the changes and close the text editor.

Step 3: Configure the lockd Module

  • Create a new file in /etc/modprobe.d/ (for example, nfs.conf) and add the following lines to set the static ports for the lockd module:
sudo mkdir -p /etc/modprobe.d
sudo nano /etc/modprobe.d/nfs.conf
# Static ports for NFS lockd
options lockd nlm_udpport=12003 nlm_tcpport=12002
  • Save the changes and close the text editor.

Step 4: Reboot the System

sudo reboot