Basic lab setup:
rhel5 - NFS Server (IP: 192.168.88.5)
rhel6 - NFS Client (IP: 192.168.88.6)
3 users: olivia, garry, paul
Check that NFS fileystem is supported by your system:
[root@rhel5 /]# cat /proc/filesystems | grep nfs
nodev nfsd
[root@rhel5 /]#
To list NFS shares:
[root@rhel5 ~]# showmount -e
Export list for rhel5:
/home 192.168.88.0/24
/inst 192.168.88.0/24
[root@rhel5 ~]#
Mount NFS volume:
#mount -t nfs 192.168.88.5:/home /home
Unmount NFS volume
#umount -f 192.168.88.5:/home
Deciding How to Mount File Systems
Q: Remote file systems frequently, such as home directories?
A:
#service autofs status
#nano /etc/auto.master
/home /etc/auto.home
If we want to mount users one by one:
[root@rhel6 /]# cat /etc/auto.home
* -fstype=nfs,rw,intr,rsize=32768,wsize=32768,hard,bg,nosuid,noexec,tcp 192.168.88.5:/home/&
/OR
olivia -fstype=nfs,rw,intr,rsize=32768,wsize=32768,hard,bg,nosuid,noexec,tcp 192.168.88.5:/home/olivia
garry -fstype=nfs,rw,intr,rsize=32768,wsize=32768,hard,bg,nosuid,noexec,tcp 192.168.88.5:/home/garry
paul -fstype=nfs,rw,intr,rsize=32768,wsize=32768,hard,bg,nosuid,noexec,tcp 192.168.88.5:/home/paul
Please note that automount will use an auto.master NIS map by default.
Thus, to force automounter to use local files, you must start is as follows:
# automount -d -f /etc/auto.master &
The other option is to edit /etc/sysconfig/autofs and uncomment line below:
#MASTER_MAP_NAME="auto.master"
To enable logging, edit /etc/sysconfig/autofs and add line below:
LOGGING="debug"
When you will mount share, they will mount automatically, but it will take some time to mount.
Mount options:
-ro Read only
-rw Mount the filesystem read and write, but can be restricted by the server, and a warning is flagged
-soft if the server fails to respond, return an error after the timeout period ( -timeo=value ) expires and don't bother to try again
-hard if the server fails to respond, retry until it does respond
-bg do the retrys in background mode
-nosuid Do not allow executables on the mounted filesystem to run as setuid.
-fstype file system type of the remote partition to mount
ext2 linux native
nfs NFS type
iso9660 CDROM
-user Allow users to mount the filesystem
-noexec Don't allow execution of files from this filesystem
-nosuid Don't allow programs in this filesystem to run as setuid or setgid
1) How to add iptables rules to allow NFS communication
This is a more complex but right solution to the given problem.
First we need to set static port for nfs services such as rquotad, mountd, statd, and lockd by editing /etc/sysconfig/nfs file.
Add/uncomment following lines in your /etc/sysconfig/nfs file:
MOUNTD_NFS_V2=no
MOUNTD_NFS_V3=no
MOUNTD_NFS_V4=yes
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662
To configure a firewall to allow NFS:
[root@rhel5 sysconfig]# cat /etc/services
nfs 2049/tcp nfsd
nfs 2049/udp nfsd
sunrpc 111/tcp portmapper # RPC 4.0 portmapper TCP
sunrpc 111/udp portmapper # RPC 4.0 portmapper UDP
2) How to restart NFSD daemon
# /etc/init.d/nfs restart
# /etc/init.d/nfslock restart
service nfs restart
service nfslock restart
On Server, check portmap
# rpcinfo -p
[root@rhel5 sysconfig]# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 679 rquotad
100011 2 udp 679 rquotad
100011 1 tcp 682 rquotad
100011 2 tcp 682 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
100021 1 udp 32769 nlockmgr
100021 3 udp 32769 nlockmgr
100021 4 udp 32769 nlockmgr
100021 1 tcp 32803 nlockmgr
100021 3 tcp 32803 nlockmgr
100021 4 tcp 32803 nlockmgr
100005 1 udp 892 mountd
100005 1 tcp 892 mountd
100024 1 udp 662 status
100024 1 tcp 662 status
[root@rhel5 sysconfig]#
We have 8 guests and no members online