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:
- 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
- Use yum to install the following services:
- yum -y install nfs-utils nfs-utils-lib
- Start the services:
- service rpcbind start
- service nfs start
- To have these services available on restart, enable them with chkconfig
- chkconfig –level 35 rpcbind on
- chkconfig –level 35 nfs on
- 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
- Set up Client
- mkdir <Client Share Directory>
- showmount -e ${SERVERIP}
- mount -t nfs ${SERVERIP}:<Server Share Directory> <Client Share Directory>
- 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:
- First there’s the obvious, are you able to ping the server’s ip address?
- 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.
- 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