How to find out how many clients are connected to my nfs server and their IP or hostname?
2 Answers
A quick method, which should work everywhere, is to list all connected sockets to the nfs port via ss on the server:
ss -a | grep nfsThere is also the showmount command:
showmount -a localhostper manpage:
showmount queries the mount daemon on a remote host for information about the state of the NFS server on that machine. With no options showmount lists the set of clients who are mounting from that host. The output from showmount is designed to appear as though it were processed through ``sort -u''.
Note that there are some caveats to it:
The completeness and accuracy of the information that showmount displays varies according to the NFS server's implementation.
Because showmount sorts and uniqs the output, it is impossible to determine from the output whether a client is mounting the same directory more than once.
So for example, if a client connects multiple times to the same mount, it will appear just once in the showmount output.
In this case with ss -a you should catch them.
Since Linux kernel 5.3 you can use special directory called /proc/fs/nfsd/clients.
You can check Kernel version by uname -r command.