Friday, 7 June 2013

How to configure NFS server in Linux

What is NFS?
  A Network File System (NFS) allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers on the network. The Network File System (NFS) is the standard for sharing files on a directory with Linux and Unix computers. It was originally developed by Sun Microsystems in the mid-1980s.
  You can create shared NFS directories directly by editing the /etc/exports configuration file, or you can create them with Red Hat's NFS Configuration tool.
NFS:-  Benefits and Problems 
Benefits:
-> DFS that allows local access to remote files.
-> Uses standard client/server architecture.
-> Using NFS the server “export” his data to other clients.
-> Provide centralize storage solution.
-> Users get their data irrespective of physical location.
Problems:
-> Network congestion.
-> Heavy disk activity on NFS server.
-> Its design assume a trusted environment, not a hostile environment.
-> NFS is based on RPC (Remote Procedural Call) which is easy to     exploit.
-> For Security reasons – NFS cannot be used over Internet. 


NFS Services

portmap   : Map calls made from other machines
nfs  : Translates NFS requests in requests on the local     system
rpc.mountd  : Mounts and Unmounts  filessystems
Server Configuration : Sharing Files 
Exported files are defined in main configuration file 

/etc/exports 

Examples : -
vi    /etc/exports
/data  *.example.com(ro,sync) station1.example.com(rw,sync)‏
/data  192.168.0.0/255.255.255.0(ro,sync)‏
Then After Exporting Files
service    portmap     start
service   nfs   start
chkconfig      --level  35   portmap   on
chkconfig      --level  35   nfs    on
Client Configuration : Mounting Shares 
Mounting can be done by using following methods
Mount command [ Temporary ]
mount    -t   nfs  192.168.0.254:/data   /mnt
/etc/fstab  file  [ Permanent ]
192.168.0.254:/data      /mnt    nfs     defaults    0   0 
Mounting NFS share on two directories on same system 
First mount to /home/data
mount   -t   nfs   x.x.x.x:/data   /home/data

Now bind /home/data to /backup
  mount   --bind   /home/data   /backup


NFS Commands  
showmount    -e     :shows the available shares
exportfs  -v     :Displays a list of shares files  and options on a server
exportfs   -a     :Exports all shares listed in  /etc/exports ,or given name
exportfs   -u     :Unexports all shares listed in  /etc/exports ,or given    name
exportfs   -r    :Refresh the server’s list after modifying  /etc/exports
NFS & TCP Wrappers:
Two services are required for TCP wrappers -
mountd 
portmap

No comments:

Post a Comment