Network File System ( NFS )
The presence of Linux workstation in a network will invariably demand the need for allowing remote file access in between system. NFS is a solution that is used to enable UNIX-UNIX file sharing. Implement a NFS server in the network so that other users of the LAN can leverage the functionalities of network file sharing.
Introduction:
NFS ( Network File System ) allows hosts to mount partitions on a remote system and use them as though they are local file systems. This allows the system administrators to store resources in a central location on the network, providing authorized users continuous access to them.
Package required for NFS:
Nfs-utils-* Include basic NFS commands and daemons
Portmap-* Supports secure NFS.RPC connections
Editing the configuration file:
To configure NFS you have to configure /etc/exports file. This is the place where you are going to mount file system that is to be shared in the network. In order to export a particular file system, we have specify it in the following format as shown below in /etc/exports file.
export host1(options)------------------------- hostN(options)
In the above format, in the place of export place the directory which you want to export. In the place of host1 specify the ip address or the network address so that a particular network can access the exported directory. And the options include read and permissions,user permissions etc.
The following methods can be used to specify host names in place of host1:
- single host --- Where one particular host is specified with fully qualified domain name, hostname, or IP Address.
- wildcards ---- Where a * or ? character is used to take into account a grouping of fully qualified domain names that match a particular string of letters. Wildcards should not be used with IP Address; however, it is possible for them to work accidentally if reverse DNS lookups fail.
Be careful when using wildcards with fully qualified domain names, as they tend to be more exact than expected. For example the use of *.example.com as a wildcard allows sales.example.com to access and exported file system but not bob.sales.example.com. To match both possibilities both *.example.com and *.*.example.com must be specified.
- IP networks --- Allows the matching of hosts based on their IP address within a larger network. For example, 192.168.0.0/28 allows the first 16 IP address, from 192.168.0.0 to 192.168.0.15, to access the exported file system but not 192.168.0.16 and higher.
OPTION |
DESCRIPTION |
ro |
Read Only permission
|
rw |
Read and Write permission
|
sync |
All data is written by request |
no_root_squash |
Allow root user to access exported directory through network |
hide |
Sharing the directory without including its sub directories for
sharing |
no_hide |
Includes sharing sub directories |
no_wdelay |
Data is written to share immediately
|
all_squash |
Treat all users as anonymous users |
An example for how to enter a directory in /etc/exports file for exporting is given below:
/home user.test.com(rw,sync)
/user1 *.test.com(rw,no_root_squash,sync)
Here in the first line the home directory can be accessed only by user.test.com. Where as in the second line user1 directory can be accessed by any system in the test.com domain. Here '*' is a wild card which specifies all clients in the domain test.com.
Exporting Files:
After specifying the directory which we want to export in the /etc/exports file, save the configuration and come out of the file and start the nfs service through command prompt using command service portmap start or /etc/init.d/portmap start.
Now for exporting the specified directory,in the command prompt use the following commands.
Command |
Description
|
exportfs -a |
Exports all directories for sharing specified in /etc/exports |
exportfs -r
|
Receives list of shared directories after changing the
configuration file |
exportfs -u
|
Unexports all directories |
exportfs -v |
Lists all currently shared directories |
Configuration on the client side for accessing directories exports through NFS:
On the client side, in order to view the directories that are exported through NFS use the following command.
#shownmount -e hostname ( IP Address of server )
Which shows all shared files. If you want to mount that directory locally you'll need an empty local directory. So create a directory such as /home/test. Now we can mount the share directory from a particular computer with the following command.
# mount -t nfs enterprise3:/usr/loca /home/test
# mount -t nfs IP address hostname:/server side directory /user side directory
In the above command, enterprise3 is the computer name from where the directory is exported and /usr/local is the exported directory and /home/test is the place where we have mounted the exported directory on to the machine through which you are accessing. '-t nfs' specifies the type of file system.
NOTE:
- A file system is a method for storing and organizing computer files and the data they contain to make it easy to find and access them. File systems may use a data storage device such as a hard disk or CD-ROM and involve maintaining the physical location of the files.
- Portmap service is required to map RPC requests to the correct services. When ever a client contacts the Portmap server with some RPC number the Portmap redirects the client to the intended service.
- RPC ( remote procedure call ) is a protocol that one program can use to request service from a program located in another computer in a network without having to understand network details. RPC uses client/server model. The requesting program is a client and service providing program is the server.
No comments:
Post a Comment