How To Configure Static Ports for NFS on Linux

This document describes the detail steps to configure NFS to use static ports for the following RPC services.
  • lockd
  • Rpc.statd
  • Rpc.rquotad
  • Rpc.mountd
The default NFS configuration uses portmap to assign random ports for above services. This behavior can be changed by modifying the NFS configuration file.
Please be advised that some Linux/UNIX distribution already define the static port sample in their configuration file. Below is a sample from RedHat Enterprise Linux.
# Define which protocol versions mountd
# will advertise. The values are "no" or "yes"
# with yes being the default
#MOUNTD_NFS_V1="no"
#MOUNTD_NFS_V2="no"
MOUNTD_NFS_V3="yes"
#
#
# Path to remote quota server. See rquotad(8)
#RQUOTAD="/usr/sbin/rpc.rquotad"
# Port rquotad should listen on.
#RQUOTAD_PORT=875
# Optinal options passed to rquotad
#RPCRQUOTADOPTS=""
#
# Optional arguments passed to in-kernel lockd
#LOCKDARG=
# TCP port rpc.lockd should listen on.
#LOCKD_TCPPORT=32803
# UDP port rpc.lockd should listen on.
#LOCKD_UDPPORT=32769
#
#
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
# Turn off v2 and v3 protocol support
#RPCNFSDARGS="-N 2 -N 3"
# Turn off v4 protocol support
#RPCNFSDARGS="-N 4"
# Number of nfs server processes to be started.
# The default is 8.
#RPCNFSDCOUNT=8
# Stop the nfsd module from being pre-loaded
#NFSD_MODULE="noload"
#
#
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
#RPCMOUNTDOPTS=""
# Port rpc.mountd should listen on.
#MOUNTD_PORT=892
#
#
# Optional arguments passed to rpc.statd. See rpc.statd(8)
#STATDARG=""
# Port rpc.statd should listen on.
#STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
#STATD_OUTGOING_PORT=2020

 

 

Application Configuration

1. Log on to the target host as root. Edit the file /etc/sysconfig/nfs. Uncomment or append the following parameter to the desired port assignment.
STATD_OUTGOING_PORT=10003
STATD_PORT=10002
MOUNTD_PORT=10004
LOCKD_UDPPORT=10001
LOCKD_TCPPORT=10001
RQUOTAD_PORT=10005
2. Once the modification is completed, save and close the configuration file. Issue the following commands to restart NFS.
# service nfs stop
# service portmap restart
# service nfs start
3. To verify the configuration of new port is active, please issue the following command.
# rpcinfo –p
The output should look similar to the following.
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 10005 rquotad
100011 2 udp 10005 rquotad
100011 1 tcp 10005 rquotad
100011 2 tcp 10005 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100005 1 udp 10004 mountd
100005 1 tcp 10004 mountd
100005 2 udp 10004 mountd
100005 2 tcp 10004 mountd
100005 3 udp 10004 mountd
100005 3 tcp 10004 mountd
Note: If you haven’t already added the services for automatic startup at boot time, you may wish to run these commands which will add to run level 3 at boot up. These services are required for nfs servers.
chkconfig --level 3 portmap on
chkconfig --level 3 nfslock on
chkconfig --level 3 nfs on

Post a Comment

Previous Post Next Post