Establishing LAN among Linux machines



Linux Sharing Service: NFS


1.Tried and tested on Slackware 10.0.

2.The configuration specified in this article is for LAN sharing between two Linux machines. For more than two machines you will have to make changes accordingly.

On a network with Linux and Unix computers, the two common sharing services are the Network File System (NFS) and the Network Information Service (NIS). NFS lets you mount remote directories seamlessly on your Linux computer. NIS allows you to keep a common database of key configuration files on your network.

This article is primarily concerned with NFS.

When you mount an NFS directory, you may not be able to tell the difference from a directory on you own computer.

Its same as “map network drive” on windows XP.

We are going to configure NFS by editing the following files:

1. /etc/hosts.allow

2. /etc/hosts.deny

3. /etc/exports


This file describes the names of the hosts which are allowed to use the local INET services.

Hence the IP addresses mentioned in this file will have access to this particular machine.


This file describes the names of the hosts which are *not* allowed to use the local INET services. It will exclude the IP addresses mentioned in /etc/hosts.allow.


This file contains a list of all directories exported to other computers (same as the drives you like to share in windows).

Basic Daemons

Few Linux services are required to run NFS smoothly. They each relate to different functions, from mounting to making sure that remote commands get to the right place.

1. portmap : portmap daemon just directs RPC traffic. If portmap is not running, NFS clients can’t find directories shared from NFS servers.

2. lockd : When files are opened through a shared NFS directory, a lock is added. The lock prevents users from overwriting the same file with different changes.

3.mountd : this is daemon for mounting NFS directories.

4. statd : There will be times when your connection to an NFS server goes down. You may have a scheduled reboot, or your server may just have crashed. The statd daemon works with lockd to help clients recover NFS connections after an NFS server reboots.

Now its time to edit the appropriate files.

# hosts.allow

portmap :

lockd :

mountd :

rquotad :

statd :

ftp :

# End of hosts.allow.

* here the IP address is of the other machine whom you would like to share your directories with.

# hosts.deny

portmap : ALL

lockd : ALL

mountd : ALL

rquotad : ALL

statd : ALL

# End of hosts.deny.

* indicating that you are allowing machine only and rejecting rest all of the machines of the world.

Setting Up Exports

Shared NFS directories are listed in /etc/exports.

# This file contains a list of all directories exported to other computers.

# It is used by rpc.nfsd and rpc.mountd.







#end of file

* a space must be left between ‘/’ and IP in the first line of this file i.e “/………)

* the path of mounted drives must be specified. e.g /root/Desktop/MyComp/C etc.

* here again the IP should be of the other machine.

some of the parameter which can be used:

  1. ro : if a directory is mounted read only.
  2. rw : if a directory is mounted read write.
  3. sync : all data is written to a share as requested.
  4. nohide: when you share the NFS directory, this automatically also shares the subdirectories.
  5. no_root_squash : this allows the root user to have full administrative access through the shared directory.

There are lot more parameters like this which can be googled on Internet. But these are the basic ones you would be requiring on simple two system LAN.

Now its time start the daemons

On the console do the following things:

#chmod +x /etc/rc.d/rc.portmap

#chmod +x /etc/rc.d/rc.nfsd

#/etc/rc.d/rc.portmap start && /etc/rc.d/rc.nfsd start

Now perform the same steps on the other computer.

now make the directory where you would like to mount the NFS shared directory.

#mkdir /mnt/NFS

#mount /mnt/NFS

similarly on second machine

#mount /mnt/NFS

If all goes well and there are no errors, the other computer disk is now mounted at the mount point.

To make the mount point permanent, make an entry in the /etc/fstab file.

This configuration will allow you to share files/directories between two computers i.e they will have peer-to-peer relation.

Instead of this you can also make one system as server and second one as client.

To achieve this make all the above file editing and Daemon running on one machine (call it as server) and mount it on the client.

This way only client will be able to access the server but not vice versa.

Bond (

Leave a Reply

Your email address will not be published. Required fields are marked *