Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menunjukkan cara menetapkan port untuk daemon statd dan nlockmgr
di VM klien untuk mempermudah konfigurasi firewall.
Filestore menggunakan daemon nlockmgr dan statd untuk mengaktifkan penguncian file. Port untuk layanan ini harus diekspos dengan benar di VM klien Anda melalui aturan firewall agar klien dapat menggunakan kunci dengan benar. Sebaiknya
tetapkan port statd dan nlockmgr agar konsisten di semua VM klien, sehingga lebih mudah untuk mengonfigurasi aturan firewall masuk.
Untuk informasi selengkapnya tentang cara menentukan apakah Anda perlu mengonfigurasi aturan firewall untuk jaringan VPC, lihat Mengonfigurasi aturan firewall.
Memeriksa setelan port
Untuk memeriksa nilai yang ditetapkan untuk port statd dan nlockmgr saat ini, jalankan
perintah berikut di instance VM klien. Jika file tidak ada, atau
jika opsi tidak memiliki nilai, port tidak akan ditetapkan. Dalam hal ini, daemon
diberi port arbitrer yang tersedia secara dinamis.
Debian/Ubuntu
Untuk menentukan port statd, jalankan perintah berikut dan lihat nilai STATDOPTS:
cat /etc/default/nfs-common
Untuk menentukan port nlockmgr, jalankan perintah berikut dan lihat nilai nlm_tcpport dan nlm_udpport:
cat /etc/modprobe.d/lock.conf
RHEL/CentOS
Untuk menentukan port statd, jalankan perintah berikut dan lihat nilai STATD_PORT:
cat /etc/sysconfig/nfs
Untuk menentukan port nlockmgr, jalankan perintah berikut dan lihat nilai nlm_tcpport dan nlm_udpport:
cat /etc/modprobe.d/lock.conf
SUSE
Jalankan perintah berikut:
cat /etc/sysconfig/nfs
Port statd tercantum di bagian STATD_PORT dan port nlockmgr
tercantum di bagian LOCKD_TCPPORT dan LOCKD_UDPPORT.
Windows
Menetapkan port NFS tidak diperlukan di Windows.
Menetapkan port
Untuk menetapkan port statd dan nlockmgr, jalankan perintah berikut di
instance VM klien. Contoh ini menggunakan editor teks
nano, tetapi Anda dapat menggunakan editor teks apa pun. Contoh ini juga menggunakan 2046 sebagai
port untuk statd dan 4045 sebagai port untuk nlockmgr karena nilai ini
adalah pilihan umum. Anda dapat menggunakan port yang berbeda berdasarkan konfigurasi jaringan. Dalam hal ini, aturan firewall masuk harus mengizinkan traffic ke
port tertentu yang Anda gunakan.
Untuk memverifikasi bahwa port NFS telah dibuka dengan benar, selesaikan langkah-langkah berikut.
Instal dependensi berikut.
Debian/Ubuntu
Dari command line, masukkan perintah berikut:
sudo apt install nfs-common tcpdump tshark
RHEL/CentOS
Dari command line, masukkan perintah berikut:
sudoyuminstallnfs-utilstcpdumpwireshark
SUSE
Dari command line, masukkan perintah berikut:
sudozypperinstallnfs-clienttcpdumpwireshark
Windows
Proses verifikasi ini tidak didukung di Windows.
Buat file skrip bernama verify-nfs-port-script.sh, salin dan tempelkan
skrip berikut di dalamnya, lalu simpan secara lokal ke komputer Anda. Catat lokasi file dan simpan untuk langkah berikutnya.
#!/bin/bash# This script is intended to run on client machines to verify that the ports# are properly open to allow the reception of NLM GRANT messages from the server.set-eu
functionkill_descendants(){forpidin$(ps-opid=--ppid"$1")dokill_descendants"$pid"doneif[[$1-ne$$]];thenkill"$1"2>/dev/null|truefi}functioncleanup{set+eu
# Kill all background jobs and wait for it to end, makes sure locks are releasedkill_descendants$$# Wait for jobs to die and locks to be released, so mount is not busysleep2umount-f"$MNT1"umount-f"$MNT2"rmdir"$MNT1"2&>/dev/null||truermdir"$MNT2"2&>/dev/null||true}functionprint_help{echo"$0 [server_ip] [mount_path]"echo-e"\t For example, if you mount a server using:"echo-e"\t\t \"mount 10.0.0.1:share /mnt/mount_point\""echo-e"\t Run the script: "echo-e"\t\t \"$0 10.0.0.1 share\""}if[$#-ne2];thenprint_help
exit1fiif[$(id-u)-ne0];thenecho"Failure! This script needs to run as root, use \"sudo $@\""exit1fiif![-x"$(command-vtshark)"];thenecho"The 'tshark' command does not exist and is needed for the script. Please install it"exit1fiif![-x"$(command-vtcpdump)"];thenecho"The 'tcpdump' command does not exist and is needed for the script. Please install it"exit1fiSERVER_IP=$1MOUNT_PATH=$2MNT1=$(mktemp-d)MNT2=$(mktemp-d)trapcleanupEXIT
echo"Mounting..."
mount-onosharecache"$SERVER_IP":"$MOUNT_PATH""$MNT1"
mount-onosharecache"$SERVER_IP":"$MOUNT_PATH""$MNT2"REC_FILE=$(mktemp/tmp/nlm_recording_XXXXXXXX.pcap)
tcpdump-iany-s0-w"$REC_FILE""host $SERVER_IP"&
TCPDUMP_PID=$!echo"Recording TCP dump to $REC_FILE"
sleep5# wait for tcpdump to start runningecho"Running test..."
flock"$MNT1"/lock_file-c"echo -n \"Got first lock: \" && date && sleep 5 && echo -n \"Releasing first lock: \" && date"&
sleep2# Wait for the first lock to actually be takenecho"Waiting for second lock: $(date)"
flock"$MNT2"/lock_file-c"echo -n \"Got second lock: \" && date"
sleep2# Wait for tcpdump to record everythingkill$TCPDUMP_PID# For quick analysis inspect recording with tshark, if you don't have it just inspect with Wiresharkecho"Inspecting results in $REC_FILE with TShark"
tshark-r"$REC_FILE"-Ynlm# First, print the output
tshark-r"$REC_FILE"-Ynlm2>/dev/null|grep-qGRANTED
EXIT_CODE=0if[$?-eq0];thenecho"The NLM GRANT message is working properly!"EXIT_CODE=0elseecho"The NLM GRANT message is not working properly!"EXIT_CODE=1fiecho"For debugging, please provide the printed output of the script, and $REC_FILE"exit${EXIT_CODE}
Masukkan perintah berikut:
chmod +x SCRIPT_PATH
Ganti kode berikut:
SCRIPT_PATH: jalur tempat file skrip Anda
berada. Perintah ini harus dijalankan sebagai root, jika tidak, tambahkan sudo ke awal
perintah.
Masukkan perintah berikut:
SCRIPT_PATHINSTANCE_IPSHARE_NAME
Ganti kode berikut:
SCRIPT_PATH: jalur tempat file skrip Anda
berada. Perintah ini harus dijalankan sebagai root. Jika tidak, tambahkan sudo ke awal
perintah.
INSTANCE_IP: alamat IP instance Filestore
SHARE_NAME: nama berbagi file
Jika port terbuka, skrip akan menampilkan respons berikut:
The NLM GRANT message is working properly!
Jika port tidak terbuka, skrip akan menampilkan error berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[[["\u003cp\u003eThis guide outlines how to configure specific ports for the \u003ccode\u003estatd\u003c/code\u003e and \u003ccode\u003enlockmgr\u003c/code\u003e daemons on client VMs to simplify firewall setup for Filestore file locking.\u003c/p\u003e\n"],["\u003cp\u003eSetting consistent \u003ccode\u003estatd\u003c/code\u003e and \u003ccode\u003enlockmgr\u003c/code\u003e ports across all client VMs is recommended to make ingress firewall rule configuration more manageable, and these ports can be checked by running specific commands.\u003c/p\u003e\n"],["\u003cp\u003eThe document provides step-by-step instructions for setting the \u003ccode\u003estatd\u003c/code\u003e and \u003ccode\u003enlockmgr\u003c/code\u003e ports on Debian/Ubuntu, RHEL/CentOS, and SUSE systems, noting that Windows does not require this configuration.\u003c/p\u003e\n"],["\u003cp\u003eAfter setting the ports, a verification process is detailed using a provided script that confirms if the ports are open and properly receiving NLM GRANT messages, and this verification process is only supported on Debian/Ubuntu, RHEL/CentOS, and SUSE systems.\u003c/p\u003e\n"]]],[],null,["# Configure NFS ports on client VMs\n\nThis page shows you how to set the ports for the `statd` and `nlockmgr` daemons\non your client VMs to make firewall configuration easier.\n\nFilestore uses the `nlockmgr` and `statd` daemons to enable file\nlocking. The ports for these services need to be properly exposed on your client\nVMs through firewall rules so that clients can properly use locks. We recommend\nsetting the `statd` and `nlockmgr` ports so that they are consistent on all\nclient VMs, making it easier to configure ingress firewall rules.\n\nFor more information on determining if you need to configure a firewall rule for\nthe VPC network, see\n[Configure firewall rules](/filestore/docs/configuring-firewall).\n\nCheck port settings\n-------------------\n\nTo check what values the `statd` and `nlockmgr` ports are currently set to, run\nthe following commands on the client VM instance. If the files don't exist, or\nif the options don't have values, then the ports aren't set. In that case, the\ndaemons are dynamically assigned arbitrary available ports. \n\n### Debian/Ubuntu\n\n1. To determine the `statd` port, run the following command and look at the\n `STATDOPTS` value:\n\n cat /etc/default/nfs-common\n\n2. To determine the `nlockmgr` port, run the following command and look at the\n `nlm_tcpport` and `nlm_udpport` values:\n\n cat /etc/modprobe.d/lock.conf\n\n### RHEL/CentOS\n\n1. To determine the `statd` port, run the following command and look at the\n `STATD_PORT` value:\n\n cat /etc/sysconfig/nfs\n\n2. To determine the `nlockmgr` port, run the following command and look at the\n `nlm_tcpport` and `nlm_udpport` values:\n\n cat /etc/modprobe.d/lock.conf\n\n### SUSE\n\nRun the following command: \n\n cat /etc/sysconfig/nfs\n\nThe `statd` port is listed under `STATD_PORT` and the `nlockmgr` port is\nlisted under `LOCKD_TCPPORT` and `LOCKD_UDPPORT`.\n\n### Windows\n\nSetting NFS ports is not required on Windows.\n\nSet ports\n---------\n\nTo set the `statd` and `nlockmgr` ports, run the following commands on the\nclient VM instance. These examples use the\n[`nano`](https://www.nano-editor.org/)\ntext editor, but you can use any text editor. These examples also use 2046 as\nthe port for `statd` and 4045 as the port for `nlockmgr` because these values\nare common choices. You can use different ports based on your network\nconfiguration. In this case, the ingress firewall rules must allow traffic to\nthe specific ports that you use.\n**Important:** If you set ports on a client VM instance that already has file shares mounted on it, you must reboot the instance for the changes to take effect. \n\n### Debian/Ubuntu\n\n- Set the `statd` port:\n\n 1. Open the `/etc/default/nfs-common` file for editing:\n\n sudo nano /etc/default/nfs-common\n\n 2. Set the `STATDOPTS` option:\n\n STATDOPTS=\"-p 2046\"\n\n 3. Save the file and exit.\n\n- Set the `nlockmgr` port:\n\n 1. Create the `/etc/modprobe.d/lock.conf` file:\n\n sudo nano /etc/modprobe.d/lock.conf\n\n 2. Set the `nlm_tcpport` and `nlm_udpport` options:\n\n options lockd nlm_tcpport=4045\n options lockd nlm_udpport=4045\n\n 3. Save the file and exit.\n\n### RHEL/CentOS\n\n- Set the `statd` port:\n\n 1. Open the `/etc/sysconfig/nfs` file for editing:\n\n sudo nano /etc/sysconfig/nfs\n\n 2. Set the `STATD_PORT` option:\n\n STATD_PORT=2046\n\n 3. Save the file and exit.\n\n- Set the `nlockmgr` port:\n\n 1. Create the `/etc/modprobe.d/lock.conf` file:\n\n sudo nano /etc/modprobe.d/lock.conf\n\n 2. Set the `nlm_tcpport` and `nlm_udpport` options:\n\n options lockd nlm_tcpport=4045\n options lockd nlm_udpport=4045\n\n 3. Save the file and exit.\n\n### SUSE\n\nSet the `statd` and `nlockmgr` ports:\n\n1. Open the `/etc/sysconfig/nfs` file for editing:\n\n sudo nano /etc/sysconfig/nfs\n\n2. Set the `STATD_PORT`, `LOCKD_TCPPORT`, and `LOCKD_UDPPORT` options:\n\n STATD_PORT=2046\n LOCKD_TCPPORT=4045\n LOCKD_UDPPORT=4045\n\n3. Save the file and exit.\n\n### Windows\n\nSetting NFS ports is not required on Windows.\n\nVerify ports are open\n---------------------\n\nTo verify NFS ports have been opened properly, complete the following steps.\n\n1. Install the following dependencies.\n\n ### Debian/Ubuntu\n\n From the command line, enter the following command: \n\n sudo apt install nfs-common tcpdump tshark\n\n ### RHEL/CentOS\n\n From the command line, enter the following command: \n\n sudo yum install nfs-utils tcpdump wireshark\n\n ### SUSE\n\n From the command line, enter the following command: \n\n sudo zypper install nfs-client tcpdump wireshark\n\n ### Windows\n\n This verification process is not supported on Windows.\n2. Create a script file called `verify-nfs-port-script.sh`, copy and paste the\n following script within it, and save it locally to your machine. Note the\n location of the file and save it for the next step.\n\n #!/bin/bash\n\n # This script is intended to run on client machines to verify that the ports\n # are properly open to allow the reception of NLM GRANT messages from the server.\n\n set -eu\n\n function kill_descendants() {\n for pid in $(ps -o pid= --ppid \"$1\")\n do\n kill_descendants \"$pid\"\n done\n if [[ $1 -ne $$ ]]; then\n kill \"$1\" 2\u003e/dev/null | true\n fi\n }\n\n function cleanup {\n set +eu\n\n # Kill all background jobs and wait for it to end, makes sure locks are released\n kill_descendants $$\n\n # Wait for jobs to die and locks to be released, so mount is not busy\n sleep 2\n\n umount -f \"$MNT1\"\n umount -f \"$MNT2\"\n\n rmdir \"$MNT1\" 2&\u003e /dev/null || true\n rmdir \"$MNT2\" 2&\u003e /dev/null || true\n }\n\n function print_help {\n echo \"$0 [server_ip] [mount_path]\"\n echo -e \"\\t For example, if you mount a server using:\"\n echo -e \"\\t\\t \\\"mount 10.0.0.1:share /mnt/mount_point\\\"\"\n echo -e \"\\t Run the script: \"\n echo -e \"\\t\\t \\\"$0 10.0.0.1 share\\\"\"\n }\n\n if [ $# -ne 2 ]; then\n print_help\n exit 1\n fi\n\n if [ $(id -u) -ne 0 ]; then\n echo \"Failure! This script needs to run as root, use \\\"sudo $@\\\"\"\n exit 1\n fi\n\n if ! [ -x \"$(command -v tshark)\" ]; then\n echo \"The 'tshark' command does not exist and is needed for the script. Please install it\"\n exit 1\n fi\n\n if ! [ -x \"$(command -v tcpdump)\" ]; then\n echo \"The 'tcpdump' command does not exist and is needed for the script. Please install it\"\n exit 1\n fi\n\n SERVER_IP=$1\n MOUNT_PATH=$2\n\n MNT1=$(mktemp -d)\n MNT2=$(mktemp -d)\n\n trap cleanup EXIT\n\n echo \"Mounting...\"\n mount -o nosharecache \"$SERVER_IP\":\"$MOUNT_PATH\" \"$MNT1\"\n mount -o nosharecache \"$SERVER_IP\":\"$MOUNT_PATH\" \"$MNT2\"\n\n REC_FILE=$(mktemp /tmp/nlm_recording_XXXXXXXX.pcap)\n tcpdump -i any -s0 -w \"$REC_FILE\" \"host $SERVER_IP\" &\n TCPDUMP_PID=$!\n echo \"Recording TCP dump to $REC_FILE\"\n\n sleep 5 # wait for tcpdump to start running\n\n echo \"Running test...\"\n flock \"$MNT1\"/lock_file -c \"echo -n \\\"Got first lock: \\\" && date && sleep 5 && echo -n \\\"Releasing first lock: \\\" && date\" &\n sleep 2 # Wait for the first lock to actually be taken\n\n echo \"Waiting for second lock: $(date)\"\n flock \"$MNT2\"/lock_file -c \"echo -n \\\"Got second lock: \\\" && date\"\n\n sleep 2 # Wait for tcpdump to record everything\n kill $TCPDUMP_PID\n\n # For quick analysis inspect recording with tshark, if you don't have it just inspect with Wireshark\n echo \"Inspecting results in $REC_FILE with TShark\"\n tshark -r \"$REC_FILE\" -Y nlm # First, print the output\n\n tshark -r \"$REC_FILE\" -Y nlm 2\u003e/dev/null | grep -q GRANTED\n EXIT_CODE=0\n if [ $? -eq 0 ]; then\n echo \"The NLM GRANT message is working properly!\"\n EXIT_CODE=0\n else\n echo \"The NLM GRANT message is not working properly!\"\n EXIT_CODE=1\n fi\n echo \"For debugging, please provide the printed output of the script, and $REC_FILE\"\n exit ${EXIT_CODE}\n\n3. Enter the following command:\n\n chmod +x \u003cvar translate=\"no\"\u003eSCRIPT_PATH\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSCRIPT_PATH\u003c/var\u003e: the path where your script file is located. This should be run as root, otherwise add `sudo` to the beginning of the command.\n4. Enter the following command:\n\n \u003cvar translate=\"no\"\u003eSCRIPT_PATH\u003c/var\u003e \u003cvar translate=\"no\"\u003eINSTANCE_IP\u003c/var\u003e \u003cvar translate=\"no\"\u003eSHARE_NAME\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSCRIPT_PATH\u003c/var\u003e: the path where your script file is located. This should be run as root, otherwise add `sudo` to the beginning of the command.\n - \u003cvar translate=\"no\"\u003eINSTANCE_IP\u003c/var\u003e: the IP address of the Filestore instance\n - \u003cvar translate=\"no\"\u003eSHARE_NAME\u003c/var\u003e: the name of the file share\n\n If the port is open, the script returns the following response: \n\n The NLM GRANT message is working properly!\n\n If the port is not open, the script returns the following error: \n\n The NLM GRANT message is not working properly!\n\nWhat's next\n-----------\n\n- [Configure firewall rules](/filestore/docs/configuring-firewall).\n- [Learn more about the networking and IP resource requirements for using\n Filestore](/filestore/docs/networking)."]]