10.6.3. Running NFS Behind a Firewall
NFS requires rpcbind
, which dynamically assigns ports for RPC services and can cause problems for configuring firewall rules. To allow clients to access NFS shares behind a firewall, edit the /etc/sysconfig/nfs
configuration file to control which ports the required RPC services run on.
The /etc/sysconfig/nfs
may not exist by default on all systems. If it does not exist, create it and add the following variables, replacing port
with an unused port number (alternatively, if the file exists, un-comment and change the default entries as required):
MOUNTD_PORT=port
Controls which TCP and UDP port mountd
(rpc.mountd
) uses.
STATD_PORT=port
Controls which TCP and UDP port status (rpc.statd
) uses.
LOCKD_TCPPORT=port
Controls which TCP port nlockmgr
(rpc.lockd
) uses.
LOCKD_UDPPORT=port
Controls which UDP port nlockmgr
(rpc.lockd
) uses.
If NFS fails to start, check /var/log/messages
. Normally, NFS will fail to start if you specify a port number that is already in use. After editing /etc/sysconfig/nfs
, restart the NFS service using service nfs restart
. Run the rpcinfo -p
command to confirm the changes.
To configure a firewall to allow NFS, perform the following steps:
Allow TCP and UDP port 2049 for NFS.
Allow TCP and UDP port 111 (rpcbind
/sunrpc
).
Allow the TCP and UDP port specified with MOUNTD_PORT="port
"
Allow the TCP and UDP port specified with STATD_PORT="port
"
Allow the TCP port specified with LOCKD_TCPPORT="port
"
Allow the UDP port specified with LOCKD_UDPPORT="port
"