我在 ubuntu 主机上运行 NAT 以连接到 linux 客户机。vmnet8 地址显示目标主机无法访问从主机本身进行 ping 操作时。
steve@hostmachine:/shared$ ifconfig -a
...
vmnet1 Link encap:Ethernet HWaddr 00:50:56:c0:00:01
inet addr:172.16.141.1 Bcast:172.16.141.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:99 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
**vmnet8** Link encap:Ethernet HWaddr 00:50:56:c0:00:08
inet addr:**192.168.238.1** Bcast:192.168.238.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14636 errors:0 dropped:0 overruns:0 frame:0
TX packets:81362 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
我看到主机上仅 ping VMNET8 接口就出现间歇性的“主机不可达”错误。
steve@hostmachine:/shared$ ping 192.168.238.130
PING 192.168.238.130 (192.168.238.130) 56(84) bytes of data.
From 192.168.238.1 icmp_seq=1 Destination Host Unreachable
From 192.168.238.1 icmp_seq=2 Destination Host Unreachable
From 192.168.238.1 icmp_seq=5 Destination Host Unreachable
From 192.168.238.1 icmp_seq=6 Destination Host Unreachable
From 192.168.238.1 icmp_seq=7 Destination Host Unreachable
为什么会发生这种情况?有什么建议可以解决此问题吗?
@september:(回应询问):目前错误没有显示出来(因此这个问题是“间歇性的”限定词)。但无论如何,这里是 netstat -rn 的输出
steve@mithril:/shared$ netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.101.204.1 0.0.0.0 UG 0 0 0 wlan0
10.101.204.0 0.0.0.0 255.255.252.0 U 0 0 0 wlan0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlan0
172.16.141.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.238.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet8
答案1
您在 mithril 上为子网 192.168.238.0 设置了错误的(默认)网关 10.101.204.1。这可能是导致问题的原因。尝试添加正确的网关(192.168.238.1):
路由添加-net 192.168.238.0 网络掩码 255.255.255.0 网关 192.168.238.1
或者
路由添加-net 192.168.238.0网络掩码255.255.255.0 gw 192.168.238.1 dev vmnet8
还要重新检查主机上的默认网关netstat -rn
更多关于Linux“route”命令。