Wednesday 16 May 2012

NFS in Linux

                The Network File System (NFS) was developed to allow machines to mount a disk partition on a remote machine as if it were on a local hard drive. This allows for fast, seamless sharing of files across a network. It also gives the potential for unwanted people to access your hard drive over the network.

NFS Configration in RHEL 6/CentOS 6

yum install nfs*

rpm packeages
nfs-utils-lib-1.1.5-4.el6.x86_64
nfs4-acl-tools-0.3.3-5.el6.x86_64
nfs-utils-1.2.3-15.el6.x86_64

vim /etc/exports
/var/ftp/pub    *(ro,sync)    #for entire network
/data    192.168.1.5(rw,sync)    #for particular machine
/jp    192.168.1.0/24(ro,sync)    #for particular network

mkdir /data
mkdir /jp

service rpcbind status
rpcbind (pid 9905) is running...

service nfs restart
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                 [  OK  ]
Shutting down NFS quotas:                                   [  OK  ]
Shutting down NFS services:                                 [  OK  ]
Starting NFS services:                                           [  OK  ]
Starting NFS quotas:                                             [  OK  ]
Starting NFS daemon:                                           [  OK  ]
Starting NFS mountd:                                            [  OK  ]

chkconfig rpcbind on
chkconfig nfs on

exportfs
/data        192.168.1.5
/jp        192.168.1.0/24
/var/ftp/pub    <world>

#see what the exported file system parameters look like
/usr/sbin/exportfs −v
exportfs -av

exporting 192.168.1.0/24:/jp
exporting 192.168.1.5:/data
exporting *:/var/ftp/pub

showmount -e 192.168.1.4
/var/ftp/pub *
/jp        192.168.1.0/24
/data        192.168.1.5

mount 192.168.1.4:/data /mnt/

#verify nfs is running
rpcinfo −p localhost run on the server
rpcinfo −p servername run on the client

#to check allow and deny
/etc/hosts.allow
/etc/hosts.deny

exportfs −ra to force nfsd to re−read the /etc/exports file.

netstat −rn should show:
Destination    Gateway        Genmask        Flags    MSS Window   irtt Iface
192.168.1.0    0.0.0.0        255.255.255.0    U               0 0                0 eth0               

nfsstat
rpm -qa | grep -i nfs
rpm -qi nfs-utils
tracepath server(IP)
# strings /sbin/portmap | grep hosts

No comments:

Post a Comment