主机无法 ping 通客户机 | Virtual Box

主机无法 ping 通客户机 | Virtual Box

我正在使用 LinuxMint17(主机),并使用 Virtual Box 运行另一个 LinuxMint17 作为客户机。

我的客户 LinuxMint 能够 ping 通主机 LinuxMint,但反之则不行。

VirtualBox 中的网络设置网络适配器 1 - 仅主机网络(我这样做是为了让客户机 IP 与主机保持一致)网络适配器 2 - NAT(为了让我的互联网在客户机上工作)

ifconfig(主机)-

 ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr 44:8a:5b:42:46:69  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:18 

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:41595 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41595 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:14653896 (14.6 MB)  TX bytes:14653896 (14.6 MB)

vboxnet0  Link encap:Ethernet  HWaddr 0a:00:27:00:00:00  
          inet addr:192.168.50.1  Bcast:192.168.50.255  Mask:255.255.255.0
          inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:508 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:90705 (90.7 KB)

wlan0     Link encap:Ethernet  HWaddr 54:27:1e:40:f0:d1  
          inet addr:192.168.1.72  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::5627:1eff:fe40:f0d1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7743461 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4638376 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10989028454 (10.9 GB)  TX bytes:411974451 (411.9 MB)

ifconfig(访客)

linuxmint@linuxmint-VirtualBox ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:97:c5:ee  
          inet addr:192.168.56.103  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe97:c5ee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1723 (1.7 KB)  TX bytes:17391 (17.3 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:06:0f:b3  
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe06:fb3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:46 errors:0 dropped:0 overruns:0 frame:0
          TX packets:145 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:22668 (22.6 KB)  TX bytes:24575 (24.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:38 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2878 (2.8 KB)  TX bytes:2878 (2.8 KB)

Ping 输出 -

主人对客人

~ $ ping 192.168.56.103
PING 192.168.56.103 (192.168.56.103) 56(84) bytes of data.
^C
--- 192.168.56.103 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 3999ms

宾客对主人

linuxmint@linuxmint-VirtualBox ~ $ ping 192.168.50.1
PING 192.168.50.1 (192.168.50.1) 56(84) bytes of data.
64 bytes from 192.168.50.1: icmp_seq=1 ttl=63 time=0.435 ms
64 bytes from 192.168.50.1: icmp_seq=2 ttl=63 time=0.185 ms
^C
--- 192.168.50.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.185/0.310/0.435/0.125 ms
linuxmint@linuxmint-VirtualBox ~ $ ping 192.168.1.72
PING 192.168.1.72 (192.168.1.72) 56(84) bytes of data.
64 bytes from 192.168.1.72: icmp_seq=1 ttl=63 time=0.250 ms
64 bytes from 192.168.1.72: icmp_seq=2 ttl=63 time=0.148 ms
^C
--- 192.168.1.72 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.148/0.199/0.250/0.051 ms

有人能指出我做错了什么吗?

答案1

什么设置了客户机上的接口 IP eth0?看起来不对;两个 IP 应该位于同一个子网

尝试(在客户机上,以 root 身份):

ip addr del 192.168.56.103/24 dev eth0
ip addr add 192.168.50.2/24 dev eth0

这将删除现有的 IP 地址,并添加位于同一子网的 IP 地址。

相关内容