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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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 Remove virbr0 and lxcbr0 Interfaces on CentOS/RHEL 6,7
  2. Understanding SELinux File Labelling and SELinux Context
  3. How to install rsyslog7 when rsyslog5 is already installed in CentOS/RHEL
  4. How to Configure rsyslog Server to Accept Logs via SSL/TLS
  5. Understanding dm-Multipath Identifiers in Linux
  6. Using initcall_debug to find kernel calls are taking a long time during boot in CentOS/RHEL
  7. How to extend ASM disk from OS level in CentOS/RHEL
  8. How to Extend the Last Existing Filesystem Partition with Parted
  9. How to find if NUMA configuration is enabled or disabled?
  10. How to Check if a Service Restart or Server Reboot is required After RPM Package Update (CentOS/RHEL/Fedora)

You May Also Like

Primary Sidebar

Recent Posts

  • SQL script to find tables that are fragmented
  • TRUNCATE TABLE not releasing space from tablespace
  • How to reclaim entire space of an oracle database table with “Truncate Table” statement
  • Oracle SQL Script to Report Tablespace Free and Fragmentation
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary