Debian VM,两个nics,无法ping通Google.com


0

我有一个基于Debian的虚拟机在VMWare Fusion上运行,带有OS X 10.9主机操作系统。

在VMWare Fusion中,我有一个专用网络设置,允许Mac和VM在不访问外部世界的情况下进行通信,这对我来说是这样我可以将SSH / SHCP连接到服务器,而无需将数据包发送到路由器。这对我来说是必要的,所以当我不在外部网络上时,我可以使用VM,例如当我在飞机上或外出时。

VMWare中的专用网络配置

除了专用网络,我希望将VM连接到公共网络,我可以不时启用或禁用它。显然,VM可能需要及时访问Internet,因此我将VM配置为具有两个网络连接。

在此输入图像描述

公共网络中的第一个,在VMWare中配置为基本上与Mac连接的任何内容。

在此输入图像描述

第二个网络是专用网络。

在此输入图像描述

这是我写的/ etc / network / interfaces文件。

# The loopback network interface
auto lo
iface lo inet loopback

# The public network interface
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

# The private network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
        address 192.168.1.250
        netmask 255.255.255.0
        gateway 192.168.1.1

据我所知,这应该工作得很好,但我的虚拟机无法ping google.com,但奇怪的是它似乎能够解决google.com到它的IP就好了。

我确信这很简单,但我需要帮助,提前谢谢!

ping结果:

cody@eureka:/$ ping google.com
PING google.com (64.233.171.139) 56(84) bytes of data.
^C
--- google.com ping statistics ---
78 packets transmitted, 0 received, 100% packet loss, time 77025ms

ifconfig结果:

cody@eureka:/$ sudo ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:a6:d9:b3  
          inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea6:d9b3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:553 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:105473 (103.0 KiB)  TX bytes:2318 (2.2 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0c:29:a6:d9:bd  
          inet addr:192.168.1.250  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea6:d9bd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:601 errors:0 dropped:0 overruns:0 frame:0
          TX packets:461 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:53403 (52.1 KiB)  TX bytes:56656 (55.3 KiB)

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:16436  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:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Answers:


2

删除eth1的默认网关。由于该接口只是本地接口,因此您不需要网关。

快速查看路线表可能会显示这是您的问题。


这似乎有效,谢谢!您是否介意一下为什么会这样有效?
Cody Smith

2
默认网关用于为其他网络路由数据包。在这种情况下,google.com的数据包通过网关路由到专用网络,并且没有将数据包路由到任何地方。因此,在删除专用网络默认网关后,使用了工作默认网关。
Tero Kilkanen 2014年

非常感谢,我认为网关命令仅用于将数据包路由到该特定接口。我没有意识到Debian会影响Debian如何选择nic来发送流量。
Cody Smith
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.