只能ping局域网,不能ping互联网

And*_*eci 2 internet dhcp ping

我有 2 台运行 Ubuntu 12.04 的计算机连接到 192.168.3 子网上的路由器。该路由器通过第一个路由器的调制解调器端口连接到另一个路由器,因此 192.168.3 路由器可以访问 192.168.2 子网。.2 路由器已连接到 Internet。我将调用 2 台计算机 A 和 B。计算机 A 可以 ping 自己、计算机 B、.3 和 .2 路由器以及 www.google.com。计算机 B 可以 ping 自身、计算机 A、.3 和 .2 路由器,但无法 ping www.google.com。我在计算机 B 上基本上没有互联网。

~$ ping www.google.com
ping: unknown host www.google.com
Run Code Online (Sandbox Code Playgroud)

ifconfig 的输出:计算机 A

eth0      Link encap:Ethernet  HWaddr 00:05:b7:dd:87:63  
      inet addr:192.168.3.135  Bcast:192.168.3.255  Mask:255.255.255.0
      inet6 addr: fe80::205:b7ff:fedd:8763/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:3940 errors:0 dropped:0 overruns:0 frame:0
      TX packets:2216 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:3365434 (3.3 MB)  TX bytes:262362 (262.3 KB)
      Interrupt:20 Memory:f7c00000-f7c20000 

eth1      Link encap:Ethernet  HWaddr 00:05:b7:dd:87:64  
      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:17 Memory:f7940000-f7960000 

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:426 errors:0 dropped:0 overruns:0 frame:0
      TX packets:426 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:35063 (35.0 KB)  TX bytes:35063 (35.0 KB)
Run Code Online (Sandbox Code Playgroud)

ifconfig 的输出:计算机 B

eth0      Link encap:Ethernet  HWaddr 00:05:b7:dd:87:43  
      inet addr:192.168.3.136  Bcast:192.168.3.255  Mask:255.255.255.0
      inet6 addr: fe80::205:b7ff:fedd:8743/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:737 errors:0 dropped:0 overruns:0 frame:0
      TX packets:551 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:73299 (73.2 KB)  TX bytes:97661 (97.6 KB)
      Interrupt:20 Memory:f7e00000-f7e20000 

eth1      Link encap:Ethernet  HWaddr 00:05:b7:dd:87:44  
      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:17 Memory:f7d40000-f7d60000 

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:336 errors:0 dropped:0 overruns:0 frame:0
      TX packets:336 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:20796 (20.7 KB)  TX bytes:20796 (20.7 KB)
Run Code Online (Sandbox Code Playgroud)

路由输出:计算机A

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.3.1     0.0.0.0         UG    0      0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 eth0
192.168.3.0     *               255.255.255.0   U     1      0        0 eth0
Run Code Online (Sandbox Code Playgroud)

路由输出:计算机B

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.3.1     0.0.0.0         UG    0      0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 eth0
192.168.3.0     *               255.255.255.0   U     1      0        0 eth0
Run Code Online (Sandbox Code Playgroud)

我能找到的唯一区别是在 resolv.conf 文件中

计算机 A 的 Resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
search ampedwireless
Run Code Online (Sandbox Code Playgroud)

ampedwireless 是 .2 路由器上 DHCP 服务器的域名。

计算机 B 的 Resolv.conf

# Generated by NetworkManager
nameserver 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

我相信计算机 B 的 resolv.conf 曾经是计算机 A 的精确副本,除了最后一行(搜索 ampedwireless),但我尝试应用某人推荐的修复程序,如下所示:

sudo apt-get remove --purge resolvconf
sudo /etc/init.d/networking restart
Run Code Online (Sandbox Code Playgroud)

我相信这个修复删除了评论,但不是我的问题。当我尝试将“search ampedwireless”手动添加到计算机 B 的 resolv.conf 时,它会被覆盖。

我试过搜索谷歌,但不幸的是,我所看到的一切都有一个略有不同的问题,修复也无济于事。我认为尝试遵循那一页的建议实际上通过删除 resolvconf 使我倒退,我无法再安装它,因为我无法访问互联网。如果有任何其他信息会有所帮助,请告诉我。提前致谢。

编辑以添加 Mark 请求的信息:计算机 A 上的 nm-tool

~$ nm-tool

** (process:3218): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: Rejected send message, 2 matched rules; type="method_call", sender=":1.45" (uid=1000 pid=3218 comm="nm-tool ") interface="org.freedesktop.DBus.Properties" member="GetAll" error name="(unset)" requested_reply="0" destination="org.freedesktop.NetworkManager" (uid=0 pid=912 comm="NetworkManager ")

NetworkManager Tool

State: unknown


** (process:3218): WARNING **: error: could not connect to NetworkManager
Run Code Online (Sandbox Code Playgroud)

计算机 B 上的 nm-tool(它们在我看来是一样的):

~$ nm-tool

** (process:1965): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: Rejected send message, 2 matched rules; type="method_call", sender=":1.40" (uid=1000 pid=1965 comm="nm-tool ") interface="org.freedesktop.DBus.Properties" member="GetAll" error name="(unset)" requested_reply="0" destination="org.freedesktop.NetworkManager" (uid=0 pid=909 comm="NetworkManager ")

NetworkManager Tool

State: unknown


** (process:1965): WARNING **: error: could not connect to NetworkManager
Run Code Online (Sandbox Code Playgroud)

在计算机 A 上挖掘:

~$ dig @8.8.8.8 google.com

; <<>> DiG 9.8.1-P1 <<>> @8.8.8.8 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46307
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     299 IN  A   173.194.46.66
google.com.     299 IN  A   173.194.46.69
google.com.     299 IN  A   173.194.46.70
google.com.     299 IN  A   173.194.46.68
google.com.     299 IN  A   173.194.46.64
google.com.     299 IN  A   173.194.46.65
google.com.     299 IN  A   173.194.46.78
google.com.     299 IN  A   173.194.46.73
google.com.     299 IN  A   173.194.46.72
google.com.     299 IN  A   173.194.46.71
google.com.     299 IN  A   173.194.46.67

;; Query time: 40 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu May 22 12:00:58 2014
;; MSG SIZE  rcvd: 204
Run Code Online (Sandbox Code Playgroud)

在计算机 B 上挖掘:

~$ dig @8.8.8.8 google.com

; <<>> DiG 9.8.1-P1 <<>> @8.8.8.8 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16939
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     41  IN  A   74.125.225.110
google.com.     41  IN  A   74.125.225.102
google.com.     41  IN  A   74.125.225.96
google.com.     41  IN  A   74.125.225.99
google.com.     41  IN  A   74.125.225.104
google.com.     41  IN  A   74.125.225.98
google.com.     41  IN  A   74.125.225.101
google.com.     41  IN  A   74.125.225.105
google.com.     41  IN  A   74.125.225.100
google.com.     41  IN  A   74.125.225.103
google.com.     41  IN  A   74.125.225.97

;; Query time: 39 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu May 22 12:00:37 2014
;; MSG SIZE  rcvd: 204
Run Code Online (Sandbox Code Playgroud)

小智 6

当您从终端运行 nm-tool 时,DNS 服务器的输出是什么?这将显示 NetworkManager 为计算机配置的 DNS 服务器。看来计算机 A 可能配置了您的 ISP 的 DNS 服务器,而计算机 B 没有配置 DNS 服务器。您可以尝试将计算机 B 上的 DNS 服务器设置为类似 Google 的 DNS(8.8.8.8、8.8.4.4)。最有可能的是 dnsmasq(一个 DNS 解析器)在本地运行以处理您系统的 DNS,但计算机 B 没有配置 DNS。运行 dig @8.8.8.8 google.com 有效吗?

老实说,我只在我的笔记本电脑上使用 NetworkManager,并且只是以“Debian 方式”配置网络接口,使用 /etc/network/interfaces 并编辑 resolv.conf。