NFS4 和远程客户端:如何显示信息?

NFS4 和远程客户端:如何显示信息?

在使用 nfsv3 的 Linux 上,命令

showmmount -d

显示远程客户端在我的 nfs 服务器上安装的目录。对于带有远程安装目录的 nfs4,showmount 命令不显示任何内容。如何知道哪个远程客户端正在我的本地计算机上使用 nfs 服务器?

答案1

由于 NFSv4 仅使用端口 tcp/2049,您可以使用以下命令简单地检查服务器上已连接的 nfs 客户端:

ss -tano state established sport nfs

答案2

找到解决方案。

netstat -ta | grep nfsd|grep ESTA|awk '{print $5}'|cut -d : -f 1

或者

ss -rta | grep nfsd|grep ESTA|awk '{print $5}'|cut -d : -f 1

并显示我所有已连接的客户。

为了显示打开的目录和使用的文件,我们可以查询旧的 procfs 假设我的客户端被识别为 215

cd /proc/fs/nfsd/clients/215

我看到 3 个文件

ctl  info  states

在文件信息中我可以看到客户端的 IP、使用的端口、主机名

clientid: ******************
address: "192.168.0.2:850"
status: confirmed
name: "Linux NFSv4.2 myclient.host.example"
minor version: 2
Implementation domain: "kernel.org"
Implementation name: "Linux 6.1.12 #1 SMP PREEMPT_DYNAMIC Sat Feb 18 16:45:16 CET 2023 x86_64"
Implementation time: [0, 0]
callback state: UP
callback address: 192.168.0.2:0

文件状态显示文件正在使用、权限和其他信息

猫国家

- ***********: { type: open, access: r-, deny: --, superblock: "00:18:4627", filename: "video/My vacations.mp4", owner: "open id:******************" }
- *********************: { type: deleg, access: r, superblock: "00:18:4627", filename: "video/My vacations.mp4" }

相关内容