无法从 WSL2 Ubuntu 22.04 中挂载 NFS

无法从 WSL2 Ubuntu 22.04 中挂载 NFS

我正在尝试在运行 Ubuntu 22.04 的 WSL2 中挂载 NFS 共享。这在原生 Ubuntu 上运行良好。我编辑 /etc/fstab 以添加:

172.16.0.113:/mnt/share/yocto-cache         /home/tom/cache    nfs    auto,nofail,noatime,nolock,intr,tcp,actimeo=1800    0    0

但我明白:

$ sudo mount -vvv /home/tom/cache
mount.nfs: timeout set for Thu Mar  9 07:57:54 2023
mount.nfs: trying text-based options 'nolock,intr,tcp,actimeo=1800,vers=4.2,addr=172.16.0.113,clientaddr=172.23.196.48'
mount.nfs: mount(2): Invalid argument
mount.nfs: trying text-based options 'nolock,intr,tcp,actimeo=1800,vers=4,minorversion=1,addr=172.16.0.113,clientaddr=172.23.196.48'
mount.nfs: mount(2): Operation not permitted
mount.nfs: trying text-based options 'nolock,intr,tcp,actimeo=1800,addr=172.16.0.113'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 172.16.0.113 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying 172.16.0.113 prog 100005 vers 3 prot TCP port 56713
mount.nfs: mount(2): Permission denied
mount.nfs: Operation not permitted

我已经尝试过解决方案[WSL 2] NIC 桥接模式

答案1

我最终访问了服务器并在尝试连接后检查了系统日志:

Jun 21 02:36:33 fileserver rpc.mountd[470]: refused mount request from 172.16.2.202 for /mnt/share/yocto-cache (/mnt/share): illegal port 53942

端口 53942 不是 WSL2 日志显示的端口,所以我假设正在进行一些端口转换。一位同事建议我尝试https://serverfault.com/a/107985/116212所以我添加了insecure一些/etc/exports并且它起作用了。

相关内容