sudo apt-get install nfs-kernel-server nfsstat (see what version of NFS you have installed on the server)
rpcinfo -p | grep nfs (ensure nfs is running and available on both udp and tcp)
sudo nano /etc/exports
share the /data folder with read plus write for everyone
only reply to requests after changes have synced to hard drive
/data *(rw,sync)
share the /srv/test folder with read plus write for a single ip)
/srv/test 10.10.10.203(rw,sync,no_root_squash)
/etc/init.d/nfs-kernel-server reload (in the old version it was /etc/init.d/nfs restart) "Assuming default behaviour ('no_subtree_check')" is good because it prevents misbehavior and ESTALE errors
by default, the portmapper assigns each NFS service to a port dynamically at service startup time... INSTEAD FOR SECURITY AND SANITY configure NFS services to use fixed ports
NFS4, ports 111 and 2049 TCP/UDP 111 - RPC 4.0 portmapper TCP/UDP 2049 - NFSD (nfs server)
all client connections from your LAN)
vi /etc/default/portmap OPTIONS=""
allow the /24 range access to portmap
vi /etc/hosts.allow
portmap: 10.10.10.
vi /etc/default/nfs-common NEED_IDMAPD=YES
FOR NFSV3 vi /etc/default/nfs-common STATDOPTS="--port 32765 --outgoing-port 32766"
vi/etc/default/nfs-kernel-server RPCMOUNTDOPTS="-p 32767" ?? RPCMOUNTDOPTS="--manage-gids --p 32767" ??
vi/etc/default/quota RPCRQUOTADOPTS="-p 32769"
vi /etc/modprobe.d/local.conf options lockd nlm_udpport=32768 nlm_tcpport=32768 options nfs callback_tcpport=32764
for sanity and clarity with netstat
vi /etc/services
rpc.nfsd 2049/tcp # RPC nfsd rpc.nfsd 2049/udp # RPC nfsd rpc.nfs-cb 32764/tcp # RPC nfs callback rpc.nfs-cb 32764/udp # RPC nfs callback rpc.statd-bc 32765/tcp # RPC statd broadcast rpc.statd-bc 32765/udp # RPC statd broadcast rpc.statd 32766/tcp # RPC statd listen rpc.statd 32766/udp # RPC statd listen rpc.mountd 32767/tcp # RPC mountd rpc.mountd 32767/udp # RPC mountd rpc.lockd 32768/tcp # RPC lockd/nlockmgr rpc.lockd 32768/udp # RPC lockd/nlockmgr rpc.quotad 32769/tcp # RPC quotad rpc.quotad 32769/udp # RPC quotad
vi /etc/init.d/nfs-kernel-server RPCMOUNTDOPTS= and change it to this: RPCMOUNTDOPTS="-p 32767"
vi /etc/modprobe.d/options.conf options lockd nlm_udpport=4045 nlm_tcpport=4045
SUGGESTED FIREWALL RULES BASED ON ABOVE: # Allow nfs mounts to local network ACCEPT fw loc udp 111 ACCEPT fw loc tcp 111 ACCEPT fw loc tcp 2049 ACCEPT fw loc udp 2049 ACCEPT fw loc tcp 32764:32769 ACCEPT fw loc udp 32764:32769
NFS CLIENT
sudo apt-get install nfs-common
apt-get install nfs-common
sudo /etc/init.d/portmap restart sudo /etc/init.d/nfs-common restart
showmount -e 192.168.1.20
rpcinfo -p 192.168.1.20 rpcinfo -u 192.168.1.20 portmap rpcinfo -u 192.168.1.20 mount rpcinfo -u 192.168.1.20 nfs
mount -F nfs [-o mount-options] server:/directory /mount-point
mount -t nfs 192.168.1.20:/srv/test /mnt/nfs
(nfs4 uses virtual directories so be careful of the paths) mount -t nfs4 10.10.10.203:/data2 /mnt/nfs
NOTE the firewall ports configured on the server above...
OR TURN OFF YOUR FIREWALLS! services iptables stop
iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT
PERMENANT ADDITION ON REBOOT VIA FSTAB
nano /etc/fstab 10.10.10.244:/ /mnt/exact/path nfs4 auto,nouser,noexec,rw,sync 0 0
for nfs3
10.10.10.244:/ /mnt/exact/path nfs auto,nouser,noexec,rw,sync 0 0
TROUBLESHOOTING
exportfs -a exportfs -r exportfs -c (access cache) exportfs -f (flush it)
sudo apt-get install portmap nfs-common sudo /etc/init.d/portmap restart sudo /etc/init.d/nfs-common restart sudo mount -t nfs 192.168.0.9:/tftpboot /mnt -o nolock
Stale NFS file handle
Error = moved or not used the "handle" or target in awhile...
try umount /mnt/dirname
then remounting it...
CENTOS NFS
yum install nfs-utils
nano /etc/exports
/home/myself 192.168.100.0/24(ro) /usr/local 192.168.0.1(ro) 192.168.0.2(ro) /home 192.168.0.1(rw) 192.168.0.2(rw) /usr/local 192.168.0.0/255.255.255.0(ro)
above represents (notice non trailing slash) directory machine1 and machine2 optionxx
ADDITIONALLY:
/etc/hosts.allow portmap: 192.168.0.1 , 192.168.0.2 lockd: 192.168.0.1 , 192.168.0.2 rquotad: 192.168.0.1 , 192.168.0.2 mountd: 192.168.0.1 , 192.168.0.2 statd: 192.168.0.1 , 192.168.0.2
/etc/hosts.deny
portmap:ALL lockd:ALL mountd:ALL rquotad:ALL statd:ALL
NFS depends on the portmapper daemon, either called portmap or rpc.portmap (/sbin or /usr/sbin) service portmap start service nfs start
CLIENT MOUNTING TO THE SERVER SHARE
first enable the client to use nfs yum search nfs-utils yum install nfs-utils
mount -t nfs -o ro 192.168.100.85:/data/altamonte /mnt/test
you may have to disable your firewall on both server and client?
/etc/init.d/iptables save
/etc/init.d/iptables stop
from the client or the server you can test the connection to the other rpcinfo -p 192.168.100.85
mount -t nfs -o ro 192.168.100.85:/data/altamonte /mnt/test once the above works you should be able to touch test.txt from the clinent in /mnt/test and see it in the server /data/altamonte dir
aix-nfs-exporting-network-sharing and mount from linux
lssrc -g nfs //shows what services are running
e.g. nfsd should be active
if not,
startsrc -s nfsd
or to start them all startsrc -g nfs
To export a directory that is not specified in the /etc/exports file, enter: exportfs [-aiuv] [-o options] [directory]
exportfs //shows what's being shared
exportfs -i /home/test //explicitly shares one directory, note it's rw by default exportfs -u /home/test //unshares the directory (removes the share) exportfs -i -o ro /home/test //shares the directory with read only permission
exportfs -i -o vers=4 /home/test //MUST have version 4 to match common linux...
mknfsexp command takes the flags and parameters specified and constructs a line that is syntactically correct for the /etc/exports file
TROUBLESHOOTING, AKA DO IT ALL AGAIN
On NFS server: 1. rmnfsexp -d /exporteddirectory 2. lssrc -g nfs 3. mknfsexp -d /exporteddirectory 4. exportfs -a
On client: 1. lssrc -g nfs 2. showmount -e nfsservername 3. mount nfsserver:/exporteddirectory /mnt
Note: If the /etc/exports file does not exist, the nfsd and the rpc.mountd daemons will not be started. You can create an empty /etc/exports file by running the touch /etc/exports command. This will allow the nfsd and the rpc.mountd daemons to start, although no file systems will be exported.
The /etc/exports file contains an entry for each directory that can be exported to NFS clients. This file is read automatically by the exportfs command. If you change this file, you must run the exportfs command before the changes can affect the way the daemon operates.
Restriction: You cannot export either a parent directory or a subdirectory of an exported directory within the same file system.
The following example illustrates entries from an /etc/exports file: /usr/games -ro,access=ballet:jazz:tap /home -root=ballet,access=ballet /var/tmp /usr/lib -access=clients /accounts/database -vers=4,sec=krb5,access=accmachines,root=accmachine1 /tmp -vers=3,ro /tmp -vers=4,sec=krb5,access=accmachines,root=accmachine1
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.commadmn/doc/commadmndita/nfs_intro.htm
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.files/doc/aixfiles/exports.htm