I have an NFS server with folder permissions as follows. There are 50 clients which need to connect to this server within the same network. I would like to know what's the command to lookup which are the clients accessing this server from the server.
NFS Server configuration file looks like this.
[root@server ~]# cat /etc/exports
/home/guests *(rw,sync)
/india *(rw,sync)
Below are the list of shared folders
[root@server ~]# showmount -e
Export list for server.sanith.com:
/india *
/home/guests *
For testing purpose I have now connected one client to the server. Below output is from the "client2" machine.
[root@client2 ~]# showmount -e 192.168.1.10
Export list for 192.168.1.10:
/india *
/home/guests *
[root@client2 ~]# mount -t nfs 192.168.1.10:/india /test
[root@client2 ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.1.10:/india on /test type nfs (rw,vers=4,addr=192.168.1.10,clientaddr=192.168.1.12)
I tried using showmount -a
and showmount -d
but not sure what am missing which's not list the client machines connected.
[root@server ~]# showmount -a
All mount points on server.sanith.com:
[root@server ~]# man showmount
[root@server ~]# showmount -d
Directories on server.sanith.com:
[root@server ~]# netstat -an | grep 192.168.1.10:2048
[root@server ~]# netstat -an | grep 192.168.1.10:2049
[root@server ~]# cat /var/lib/nfs/rmtab
[root@server ~]#
Note : The firewall is disabled on the server temporarily during this testing. Please advise.
Select Programs and Features. Select Turn Windows Features on or off. Select Services for NFS. Select the check box Client for NFS and click OK.
NFS clients can use the showmount -e command to see a list of exports available from an ONTAP NFS server.
You can find connected NFS clients by running the following on the NFS server:
netstat | grep :nfs
NFS works over both UDP and TCP, only open TCP connections will show in netstat
or ss
. Also, as a distributed filesystem, it has (historically) had its fair share of problemsPDF (state, cache, locking, notifications, security — some of which have solutions through extra RPC features, e.g. rpc.statd
).
On a Linux NFS server (see man rpc.mountd
) the client mount/unmount requests are recorded in /var/lib/nfs/rmtab
, just like /etc/mtab
, sothe answer should be:
cat /var/lib/nfs/rmtab
If it's empty, then you either have a problem with rpc.mountd
(so you should check the RPC services running), or all the clients are NFSv4 which doesn't use this feature.
On versions I've checked rmtab
is presented as:
10.1.2.0/24:/path/to/export1:0x000...flags
10.1.2.10:/path/to/export1:0x0000...flags
10.1.2.22:/path/to/export1:0x0000...flags
10.1.2.0/24:/path/to/export2:0x000...flags
10.1.2.22:/path/to/export2:0x0000...flags
10.1.2.99:/path/to/export2:0x0000...flags
i.e., each mount point is listed, followed by the clients using it.
Note the caveat in the man page:
However, this file is mostly ornamental. One, the client can continue to use the file handle even after calling rpc.mountd's UMOUNT procedure. And two, if a client reboots without notifying rpc.mountd, a stale entry will remain in rmtab.
The /proc/fs/nfsd/client
approach (@Vsevolod Gromov's answer) in newer kernels should be better in this respect, but because it only supports NFSv4 clients which should be better behaved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With