Saturday, 1 March 2014

Find NFS Clients Connected to NFS Server


Question: How to find Find  NFS Clients Connected to NFS Server

You can say it very simple by using 

showmount -e  <NFS Server Name>

# showmount -e umbox04
export list for umbox04:
/gpfs/edw/common  umlpar1 umlpar2 umlpar3 umlpar4 umlpar5
/export/nim      udaixserv1,udaixserv2,udaixserv3,udaixserv4,udaixserv5
/bigdata (everyone)

but there is a problem here, if the nfs mount is shared as everyone ( say /bigdata in the above example) you will not be able to tell ,to which clients are  using it.

In-order to overcome above issues ,there are two ways to find the NFS clients connected to  NFS server.

1. Using "netstat":

The idea with  "netstat" is an indirect method . We use nfs port which is 2049 to get the clients information.
netstat -an | grep nfs.server.ip:port
If your nfs server IP address and port is 2049, enter:
Sample outputs:
# netstat -an | grep
tcp        0      0         ESTABLISHED
tcp        0      0         ESTABLISHED


  • - NFS serer IP address
  •     2049 - NFS server port
  • and - NFS clients IP address

2. Using showmount command

You can to use the showmount command to see mount information for an NFS server. The following command should not be used as it may produce unreliable result (you can type this command on any one of the nfs client):
showmount -a <NFS Server Name>
Sample outputs:
All mount points on mynfsserv01:

#showmount -a mynfsserv01

  • -a: List both the client hostname or IP address and mounted directory in host:dir format. This info should not be considered reliable.

As per the rpc.mountd(8) man page:
he rpc.mountd daemon registers every successful MNT request by adding an entry to the /var/lib/nfs/rmtab file. When receivng a UMNT request from an NFS client, rpc.mountd simply removes the matching entry from /var/lib/nfs/rmtab, as long as the access control list for that export allows that sender to access the export.

Clients can discover the list of file systems an NFS server is currently exporting, or the list of other clients that have mounted its exports, by using the showmount(8) command. showmount(8) uses other procedures in the NFS MOUNT protocol to report information about the server's exported file systems.

Note, however, that there is little to guarantee that the contents of /var/lib/nfs/rmtab are accurate. A client may continue accessing an export even after invoking UMNT. If the client reboots without sending a UMNT request, stale entries remain for that client in /var/lib/nfs/rmtab.

0 blogger-disqus:

Post a Comment