• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Configure NFS Services (server-side) to Run on Static Ports as an Alternative CentOS/RHEL 5 and 6

by admin

By default, some NFS services (server_side) use well-known ports but some normally just use random ports. The use of random ports does not work so well with strict firewall rules blocking random yet unknown ports. So, sometimes it is best to manually alter or specify static ports for NFS services (server_side) to use.

This post describes how to configure NFS services (server-side) to run on static ports as an alternative.

Overview

NFS services (server-side) include:

  • NLM (NFS lock manager or in-kernel lockd)
  • rpc.mountd
  • rpc.nfsd
  • rpc.rquotad
  • rpc.statd

Please note lockd and rpc.statd also run on NFS clients. Also, rpc.rquotad is not strictly a part of the NFS family but is used to check quotas on file systems shared by the NFS server and mounted by one or more NFS clients.

With NFSv3, rpc.nfsd interacts with LOCKD/NLM, rpc.mountd, and rpc.statd. However, with NFSv4, all these interactions are now incorporated/consolidated.

For CentOS/RHEL 5 and 6, the nfs-utils RPM ships /etc/sysconfig/nfs as the main NFS (server-side) configuration file. The static ports for rpc.nfsd and rpc.rquotad default to 2049 and 875, respectively, since they are considered well-known ports. Other NFS services (server-side), such as LOCKD/NLM, rpc.mountd, and rpc.statd, normally just use random ports, but /etc/sysconfig/nfs does offer example port values for reference. The example port values are good enough for most scenarios.

# cat /etc/services
nfs     2049/tcp nfsd shilp # Network File System
nfs     2049/udp nfsd shilp # Network File System

rquotad 875/tcp             # rquota daemon
rquotad 875/udp             # rquota daemon
# cat /etc/sysconfig/nfs
# TCP port rpc.lockd should listen on.
#LOCKD_TCPPORT=32803
# UDP port rpc.lockd should listen on.
#LOCKD_UDPPORT=32769

# Port rpc.mountd should listen on.
#MOUNTD_PORT=892

# Port rquotad should listen on.
#RQUOTAD_PORT=875

# Port rpc.statd should listen on.
#STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
#STATD_OUTGOING_PORT=2020

Examples of configuring /etc/sysconfig/nfs

To specify LOCKD/NLM to use free static ports, you just uncomment LOCKD_TCPPORT and LOCKD_UDPPORT to set the new port values, then restart the nfs service or the nfslock service.

LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769

To specify rpc.mountd to use a free static port, you just uncomment MOUNTD_PORT to set the new port value, then restart the nfs service.

MOUNTD_PORT=892

To specify rpc.nfsd to use a free static port other than 2049, you just uncomment RPCNFSDARGS to add the new port value, then restart the nfs service.

RPCNFSDARGS="-p 20499"

To specify rpc.rquotad to use a free static port other than 875, you just uncomment RQUOTAD_PORT to set the new port value, then restart the nfs service.

RQUOTAD_PORT=8755

To specify rpc.statd to use free static ports, you just uncomment STATD_PORT and STATD_OUTGOING_PORT to set the new port values, then restart the nfslock service.

STATD_PORT=662
STATD_OUTGOING_PORT=2020

Service Control

Restart the nfs service:

# service nfs restart

Restart the nfslock service:

# service nfslock restart

Verification:

# rpcinfo -p

Filed Under: CentOS/RHEL, CentOS/RHEL 5, CentOS/RHEL 6

Some more articles you might also be interested in …

  1. How to Customize Linux Password Expiration and Complexity Requirements
  2. How to change the number of commands stored in Bash History
  3. “Could not resolve proxy: https; Unknown error” – error with ‘yum update’
  4. “yum update” fails with “[package version 1] is a duplicate with [package version 2]”
  5. How to enable additional scsi logging in CentOS/RHEL
  6. Understanding Linux SCSI Reservation
  7. Error: Can’t open display: hostname:x.y when running xclock
  8. What does refid value “.LOCL.” mean in NTP
  9. How to Enable Thin LVM Automatic Extension
  10. CentOS/RHEL: “id” command doesn’t list the Group Name against GID for LDAP Users

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright