Debian VM 可以看到网络上的其他计算机,但无法连接到 WWW

Debian VM 可以看到网络上的其他计算机,但无法连接到 WWW

类似于这个SU问题:https://superuser.com/questions/667631/network-is-unreachable-when-attempting-to-ping-google-but-internal-addresses

实际上,这几乎是相同的基本问题。我通过该线程试图找到解决方案,我更改了 resolv.conf:

before:
domain [my work domain]
search [my work domain]
nameserver [my network DHCP]
nameserver [my network DHCP2]

我把它改为:

after:
domain [my work domain]
search [my work domain]
nameserver 8.8.8.8
nameserver 8.8.4.4

但是,每当我重新启动计算机时,resolv.conf 都会被覆盖为以前的版本(上面的“之前”)。 (也没有解决问题)

在我安装了 virtualbox 添加项(又名全新安装,安装 Samba 后,它可以在互联网和我的内部网络上完美运行)、X 服务器和(特别是)LXDE 后,问题就开始了:

apt History.log 的猫:

Start-Date: 2014-08-21  10:03:42
Commandline: apt-get install virtualbox-guest-utils virtualbox-guest-dkms
Install: x11-xkb-utils:amd64 (7.7+1, automatic), libxaw7:amd64 (1.0.12-2, automatic), xfonts-utils:$
End-Date: 2014-08-21  10:03:56

Start-Date: 2014-08-21  10:18:39
Commandline: apt-get install lxde
Install: desktop-base:amd64 (7.0.3, automatic), libgoa-1.0-0b:amd64 (3.12.4-1, automatic), lxmenu-d$
End-Date: 2014-08-21  10:21:52

Start-Date: 2014-08-21  10:26:40
Commandline: apt-get upgrade
Upgrade: libio-socket-ssl-perl:am

来宾上的 ifconfig:

root@Peridot:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:89:c9:20  og
          inet addr:172.31.2.102  Bcast:172.31.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe89:c920/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2281 errors:0 dropped:1 overruns:0 frame:0
          TX packets:463 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:266507 (260.2 KiB)  TX bytes:120554 (117.7 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:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 B)  TX bytes:240 (240.0 B)

VBox 中的适配器是直接连接到我的以太网连接的桥接适配器;我的其他 2 个虚拟机也是如此(可以工作)

我尝试过的其他问题:

编辑:

网络统计:

root@Peridot:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.13.36.0      172.31.2.254    255.255.255.0   UG        0 0          0 eth0
172.31.2.0      *               255.255.255.0   U         0 0          0 eth0

/etc/网络/接口:

root@Peridot:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

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

这个问题我已经完成了以下操作,但没有成功(thapphireth是我的本地计算机托管虚拟机。如果我 ping 网络上的其他计算机也有效):

root@Peridot:~# ps aux | grep dhclient
root      1849  0.0  1.3  14848  6984 ?        Ss   14:28   0:00 dhclient -v -pf                                                                                                                                                              /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
root      1960  0.0  0.1  12680   940 pts/0    S+   14:30   0:00 grep dhclient
root@Peridot:~# ps aux | grep dhclient
root      1849  0.0  1.3  14848  6984 ?        Ss   14:28   0:00 dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
root      1963  0.0  0.1  12680   940 pts/0    S+   14:30   0:00 grep dhclient
root@Peridot:~# kill 1849
root@Peridot:~# ps aux | grep dhclient
root      1965  0.0  0.1  12680   940 pts/0    S+   14:30   0:00 grep dhclient
root@Peridot:~# dhclient eth0
RTNETLINK answers: File exists
root@Peridot:~# ping google.com
connect: Network is unreachable
root@Peridot:~# ping thapphireth
PING thapphireth.SID (172.31.2.67) 56(84) bytes of data.
64 bytes from 172.31.2.67: icmp_seq=1 ttl=128 time=0.269 ms
64 bytes from 172.31.2.67: icmp_seq=2 ttl=128 time=0.428 ms
^C
--- thapphireth.SID ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.269/0.348/0.428/0.081 ms
root@Peridot:~# ps aux | grep dhclient
root      2009  0.0  1.3  14848  6984 ?        Ss   14:30   0:00 dhclient eth0
root      2013  0.0  0.1  12680   944 pts/0    S+   14:30   0:00 grep dhclient
root@Peridot:~# kill 2009
root@Peridot:~# dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/08:00:27:89:c9:20
Sending on   LPF/eth0/08:00:27:89:c9:20
Sending on   Socket/fallback
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 172.31.2.42
RTNETLINK answers: File exists
bound to 172.31.2.102 -- renewal in 277205 seconds.
root@Peridot:~# ping google.com
connect: Network is unreachable
root@Peridot:~# ping thapphireth
PING thapphireth.SID (172.31.2.67) 56(84) bytes of data.
64 bytes from 172.31.2.67: icmp_seq=1 ttl=128 time=0.251 ms
64 bytes from 172.31.2.67: icmp_seq=2 ttl=128 time=0.798 ms
^C
--- thapphireth.SID ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.251/0.524/0.798/0.274 ms
root@Peridot:~#

Windows(主机)上 ipconfig 的结果:

Windows IP Configuration
Ethernet adapter vEthernet (Broadcom NetLink (TM) Gigabit Ethernet Virtual Switch):

   Connection-specific DNS Suffix  . : SID
   Link-local IPv6 Address . . . . . : fe80::5d00:6fe1:98d2:ac06%9
   IPv4 Address. . . . . . . . . . . : 172.31.2.67
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.31.2.1

答案1

的输出netstat -r不包含默认路由。

这应该通过 VM 主机软件的 DHCP 来实现。

编辑:

您可以尝试使用包中的rtmon和 来找出默认路由是否已配置ipip路由。您rtmon可以查看内核的 netlink 接口,也ip可以查看这些日志。

关闭界面ifdown eth0并启动rtmon如下:

rtmon file /var/log/rtmon.log

然后使用 激活网络接口ifup eth0。获得 IP 地址后,使用以下命令查看日志

ip monitor file /var/log/rtmon.log | less

寻找类似的东西

default via 172.31.2.x dev eth0

如果找到它,则可能是从 DHCP 获得了默认路由,并且问题出在虚拟机的某个位置。如果找不到,则可能是 DHCP 有问题。

答案2

您的虚拟机除了从 DHCP 服务器获取 IP 之外,还获取名称服务器。您可以在 DHCP 服务器上覆盖此设置,也可以设置 Debian VM 以注入其自己的选项。

请看一下我对其他 U&L 问答题的回答,了解如何实现这一目标:如果 Debian 机器使用 DHCP,我可以将其设置为使用 OpenDNS 名称服务器吗?。在此我展示了 2 个关于如何执行此操作的方法,其他 2 个答案显示了您可以向 dhcpclient 提供的配置选项,以指示它如何覆盖。

相关内容