看来我偶然发现了虚拟机中 NFS 的这个普遍问题。长话短说,我尝试启动一个使用 NFS 的 FOG 服务器。
- NFS 服务器 VM 主机处于桥接模式,IP 为:10.0.0.136
- 可以从物理主机上的其他虚拟机挂载 NFS 共享,但不能从其他 LAN 设备挂载。
- 无论我使用什么 VM 平台,虚拟机都处于 NAT Bridge 模式。
- 防火墙已禁用-端口..是..打开..
- 运行 VM 平台的物理机是 Windows 10 Home,禁用防火墙和 Intel 网络适配器。
问题: 当我从其他 LAN 设备安装时,我收到“连接超时”的提示,但 showmount 在 2 分 10 秒后响应。此测试是从同一 LAN 网络上的 Synology-NAS 执行的。
# mount -v -t nfs nfsserver:/images /volume1/test
mount.nfs: timeout set for Tue Jan 30 23:43:55 2018
mount.nfs: trying text-based options 'vers=3,tcp,soft,nolock,addr=10.0.0.136'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100005 vers 3 prot TCP port 56755
mount.nfs: mount(2): Connection timed out
mount.nfs: trying text-based options 'vers=3,tcp,soft,nolock,addr=10.0.0.136'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100005 vers 3 prot TCP port 56755
mount.nfs: mount(2): Connection timed out
mount.nfs: trying text-based options 'vers=3,tcp,soft,nolock,addr=10.0.0.136'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100005 vers 3 prot TCP port 56755
# showmount -e nfsserver
Export list for 10.0.0.136:
/images/dev 10.0.0.0/24
/images 10.0.0.0/24
当我从同一 VM 平台上的另一个 VM 主机挂载时,它可以按预期工作 - 在本例中为 Debian 9/VirtualBox:即时挂载并即时“showmount -e”响应。
# mount -vt nfs nfsserver:/images /mnt/test
mount.nfs: timeout set for Wed Jan 31 01:03:30 2018
mount.nfs: trying text-based options 'vers=4.2,addr=10.0.0.136,clientaddr=10.0.0.108'
mount.nfs: mount(2): No such file or directory
mount.nfs: trying text-based options 'addr=10.0.0.136'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 10.0.0.136 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 10.0.0.136 prog 100005 vers 3 prot UDP port 33485
这是我在 nfsserver 上的 /etc/exports:
# cat /etc/exports
/images 10.0.0.0/24(ro,sync,no_wdelay,no_subtree_check,insecure_locks,no_root_squash,insecure,fsid=0)
/images/dev 10.0.0.0/24(rw,async,no_wdelay,no_subtree_check,no_root_squash,insecure,fsid=1)
这是防火墙(已禁用):
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
服务正在监听:
# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 48327 mountd
100005 1 tcp 47113 mountd
100005 2 udp 50106 mountd
100005 2 tcp 46029 mountd
100005 3 udp 38832 mountd
100005 3 tcp 46131 mountd
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049
100227 3 tcp 2049
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 2 udp 2049
100227 3 udp 2049
100021 1 udp 36259 nlockmgr
100021 3 udp 36259 nlockmgr
100021 4 udp 36259 nlockmgr
100021 1 tcp 45767 nlockmgr
100021 3 tcp 45767 nlockmgr
100021 4 tcp 45767 nlockmgr
LAN 设备的端口扫描超时,显示开放端口:
# nmap -p 111,2049 -T4 -A nfsserver
Starting Nmap 7.40 ( https://nmap.org ) at 2018-01-31 00:22 CET
Nmap scan report for nfsserver (10.0.0.136)
Host is up (0.00079s latency).
rDNS record for 10.0.0.136: nfsserver
PORT STATE SERVICE VERSION
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100003 2,3,4 2049/tcp nfs
| 100003 2,3,4 2049/udp nfs
| 100005 1,2,3 38832/udp mountd
| 100005 1,2,3 46131/tcp mountd
| 100021 1,3,4 36259/udp nlockmgr
| 100021 1,3,4 45767/tcp nlockmgr
| 100227 2,3 2049/tcp nfs_acl
|_ 100227 2,3 2049/udp nfs_acl
2049/tcp open nfs_acl 2-3 (RPC #100227)
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 6.33 seconds
/etc/hosts.allow
并且/etc/hosts.deny
都是空的:
# cat /etc/hosts.allow /etc/hosts.deny
#
到目前为止,我已经在以下位置复制了该问题:
- RHEL 7 / VirtualBox
- Debian 9 / VirtualBox
- Fedora 13 / VirtualBox
- Debian 9 / VMWare Workstation Player 14
- Ubuntu 16 / VMWare Workstation Player 14
很奇怪!尝试了将近一周后,我向你们投降了,强大的 Serverfault 之神
我很无知并且很谦虚!
如何挂载到虚拟机中运行的 NFS 服务器而不超时?
编辑:感谢格式化。我尝试对两端进行 tcpdump,似乎有些数据包从未到达虚拟机内的 NFS 服务器。这看起来像是 VirtualBox 内部的网络问题。但仍然一无所知。
答案1
我不知道为什么这个问题会发生在虚拟机中,但如果我使用版本 3 安装它就可以了。
mount -t nfs -o vers=3,nolock,proto=tcp nfsserver:/images /volume1/test
找到了解决方案,但无法真正解释..?