我在主机上设置了一个 NFS 服务器,并在文件中进行了以下设置/etc/exports
:
/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave *(rw,sync,no_root_squash)
我还向主机提供了以下ufw
防火墙配置:
Anywhere on vboxnet0 ALLOW 2049 (log)
Anywhere (v6) on vboxnet0 ALLOW 2049 (v6) (log)
Anywhere ALLOW OUT 80 on vboxnet0
vboxnet0
仅主机 VirtualBox 网络在哪里:
我也在我的主机上运行了rpcinfo -p | grep nfs
以下结果:
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
在我的虚拟机上我有以下网络接口:
enp0s3 Link encap:Ethernet HWaddr 08:00:27:4e:5d:88
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe4e:5d88/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26355 errors:0 dropped:0 overruns:0 frame:0
TX packets:12806 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:20957730 (20.9 MB) TX bytes:777044 (777.0 KB)
enp0s8 Link encap:Ethernet HWaddr 08:00:27:80:69:57
inet addr:192.168.56.102 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe80:6957/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3688 errors:0 dropped:0 overruns:0 frame:0
TX packets:8851 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:351598 (351.5 KB) TX bytes:762540 (762.5 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:160 errors:0 dropped:0 overruns:0 frame:0
TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:11840 (11.8 KB) TX bytes:11840 (11.8 KB)
enp0s8
主机专用接口在哪里?但是当我运行:
sudo mount 192.168.56.1:/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave ~/MyFirstEnclave
我收到以下错误:
mount.nfs: Connection timed out
我也尝试做了netcat 192.168.56.1 2049
但没有结果。
你知道为什么会发生这种情况吗?
编辑1
根据评论中的建议,我禁用了防火墙。现在我这样做:
sudo mount 192.168.56.1:/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave ~/MyFirstEnclave
我收到以下错误:
mount.nfs: access denied by server while mounting 192.168.56.1:/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave
编辑2:
我也在主机上这样做了sudo exportfs -a
,但出现错误:
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
答案1
在虚拟机上运行mount
如下命令:
sudo mount -t nfs -o proto=tcp,port=2049 192.168.56.1:/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave ~/MyFirstEnclave
在上面的命令中,查看您直接告诉使用协议和端口挂载 nfs 共享的-o proto=tcp,port=2049
参数。-t nfs
tcp
2049
然后您可以通过以下方式卸载它:
sudo fusermount -u ~/MyFirstEnclave
此外,建议使用以下gufw
设置(gui 是希腊语,但您也可以从表单的元素位置来理解):
此外,如果您希望永久挂载您的虚拟机,请尝试将以下设置放入您的/etc/fstab
:
192.168.56.1:/home/pcmagas/Kwdikas/C++/intelSGX/MyFirstEnclave /home/user/MyFirstEnclave nfs rsize=8192,wsize=8192,timeo=14,intr,tcp,port=2049
请注意tcp,port=2049
您告诉使用 tcp 和 connent 进入服务器端口的条目部分2049
。