微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ubuntu Server 12.04可以访问LAN但不能访问Internet

通过命令行使用Ubuntu Server(12.04),我可以访问LAN(例如ping本地机器)但不能访问互联网(例如“ping google.com”或“sudo apt-get update”).我应该如何解决这个问题?

我首先要说的是我能够访问互联网(使用sudo apt-get),但经过一些“配置工作”后,我现在只能访问局域网了.它曾经在我有DHCP连接时工作.在我切换到静态IP后的某个时间,我注意到了这个问题.我已经切换回DHCP但没有运气.

/ etc / network / interfaces目前看起来像这样:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid myrouteRSSid
wpa-psk myrouterpassword

ifconfig -a报告:

eth0      Link encap:Ethernet  HWaddr 00:1e:7a:d9:1b:07
          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:68ff:fed9:1b07/64 Scope:Link
          UP broADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:217 errors:0 dropped:0 overruns:0 frame:0
          TX packets:414 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:23826 (23.8 KB)  TX bytes:47487 (47.4 KB)
          Interrupt:16

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:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:720 (720.0 B)  TX bytes:720 (720.0 B)

virbr0    Link encap:Ethernet  HWaddr 86:19:a7:9b:a6:4a
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          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:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:94:ea:de:1f:78
          inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::216:eaff:fede:1f78/64 Scope:Link
          UP broADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:328 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:58008 (58.0 KB)  TX bytes:1852 (1.8 KB)

“ping 192.168.0.1”(网关)有效. “ping 192.168.0.100”(自我)有效. “ping 192.168.0.7”(另一台PC)有效. “ping google.com”报告“ping:未知主机google.com”. “ping 173.194.34.72”(google.com)失败.

我也可以从另一台PC通过SSH连接到这个ubuntu服务器(虽然它现在等待大约20秒才会要求输入密码,而以前它是瞬时的 – 重要吗?)

编辑:路由-n报告:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    100    0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
你的resolv.conf条目可能不好.您应该确定正确的地址并在resolv.conf中手动编写它们(删除当前条目).
我猜DNS服务器与网关(192.168.0.1)相同.

您可以在通过命令在resolv.conf中进行更改之前尝试此操作:

dig @192.168.0.1 google.com

上面的命令尝试询问google.com IP的192.168.0.1(不是你在resolv.conf中的当前设置),如果有工作的DNS服务器,答案将包含以下文本:

;; ANSWER SECTION:
google.com.             300     IN      A       173.194.35.162
google.com.             300     IN      A       173.194.35.161
google.com.             300     IN      A       173.194.35.164
[...]

如果失败,请尝试在dig命令中输入不同的IP

一个问题是尝试通过IP ping google失败(正如你所写).要快速测试失败的原因,请尝试以下命令:

traceroute 173.194.35.162

您将看到哪一个跳跃导致问题.您的网关可能无法正常工作.

原文地址:https://www.jb51.cc/ubuntu/348176.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐