Configure NFS ports
Configuring NFS (Network File System) ports is essential for enabling communication and data transfer between NFS clients and servers securely within a network. NFS relies on specific port numbers for its operations, and ensuring these ports are properly configured is crucial for facilitating file sharing and access.
By default, NFS uses port 2049 for its main operations, such as file read, write, and metadata requests. Additionally, NFS may use other ports for specific purposes, such as port 111 for RPC (Remote Procedure Call) and port 1110 for mountd, the NFS mount daemon.
Prerequisites
GCP account
Open Console.
Open Cloud Shell
Paste the below code
$ cat /etc/default/nfs-common
It will display the nfs-common file. In this file we can see STATDOPS have no value.
Paste the code below to open the nfs-common file
$ sudo nano /etc/default/nfs-common
It will open the file.
Change STATDOPTS="-p 2046"
Then press Ctrl + x then y to confirm following press Enter.
Open
$ cat /etc/modprobe.d/lock.conf
If its displaying No such file or directory, then Open the file
$ sudo nano /etc/modprobe.d/lock.conf
In this file Paste the below code
options lockd nlm_tcpport=4045
options lockd nlm_udpport=4045
Then press Ctrl + x then y to confirm following press Enter.
Paste the below code
$ cat /etc/default/nfs-common
It will display the nfs-common file with the STATDOPS value updated.
Open
$ cat /etc/modprobe.d/lock.conf
It’ll display the updated lock.conf file