RHEL6.x NFS Config

If you’ve still got some RHEL 6.x systems in your environment and you need them to share directories via NFS you may struggle as I did to find all the settings for turning on services and opening up ports. Here’s a step by step walkthrough of what I did:

  1. First take note of your server and client IP addresses, I’ll be using the following addresses as examples:
    • SERVERIP=192.168.1.100
    • CLIENTIP=192.168.1.101
  2. Use yum to install the following services:
    • yum -y install nfs-utils nfs-utils-lib
  3. Start the services:
    • service rpcbind start
    • service nfs start
  4. To have these services available on restart, enable them with chkconfig
    • chkconfig –level 35 rpcbind on
    • chkconfig –level 35 nfs on
  5. On the server, set up your export directory
    • mkdir <Server Shared Directory>
    • echo “<ServerShared Directory> ${CLIENTIP}(rw,sync,no_root_squash)” > /etc/exports
    • OR >>/etc/exports if that file already exists
    • See the note below for a full set of filesystem options
  6. Set up Client
    • mkdir <Client Share Directory>
    • showmount -e ${SERVERIP}
    • mount -t nfs ${SERVERIP}:<Server Share Directory> <Client Share Directory>
  7. Add your mount to the client’s fstab if you want the Server Share to mount at boot time
    • vi /etc/fstab
    • ${SERVERIP}:/nfsshare /mnt nfs defaults 0 0

NOTE: Filesystem Options

  • ro: READ ONLY client will only be able to read the server share
  • rw: READ/WRITE client and read and write to and from the shared directory
  • sync: SYNC confirms requests to the shared directory only once the changes have been committed.
  • no_root_squash: Allows root to connect to the server share

Troubleshooting

The moment of truth will come at step 6b. when you issue the showmount -e command on the client side. If this step returns an error, or worse nothing at all please consider the following troubleshooting steps:

  1. First there’s the obvious, are you able to ping the server’s ip address?
  2. Run service rpcbind status and service nfs status on the server side to verify that the necessary services are running and then run rpcinfo -p ${SERVERP} to get RPC info from the server.
  3. Is the iptables service running? Execute service iptables status on the server side to verify. If iptables is running it will be necessary to open ports 111 and 2049 to let nfs through.
    • iptables -A INPUT -p tcp –dport 111 -j ACCEPT
    • iptables -A INPUT -p udp –dport 111 -j ACCEPT
    • iptables -A INPUT -p tcp –dport 2049 -j ACCEPT
    • iptables -A INPUT -p udp –dport 2049 -j ACCEPT

dcd

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.