我刚刚设置了一个 Linux 服务器。但目前我在与外界连接时遇到问题。我无法执行 wget、apt-get 或 ping。以下是一些相关细节:
$ping google.com
ping: unknown host google.com
cat /etc/resolv.conf
search dmust.local
nameserver 198.154.126.1
vim /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
iface eth0 inet static
address 198.154.126.179
netmask 255.255.255.0
network 198.154.126.0
broadcast 198.154.126.255
gateway 198.154.126.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 198.154.126.1
dns-search dmust.local
更新
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
198.154.126.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 198.154.126.1 0.0.0.0 UG 100 0 0 eth0
grep '^hosts' /etc/nsswitch.conf
hosts: files dns
答案1
您需要从配置中删除不正确的名称服务器。
查看https://help.ubuntu.com/12.10/serverguide/network-configuration.html#name-resolution了解更多信息。
要使用 Google 的免费名称服务器,请按如下方式编辑 /etc/network/interfaces 文件。
消除:
dns 名称服务器 198.154.126.1
添加:
dns 名称服务器 8.8.4.4 8.8.8.8
然后重新启动您的网络接口,通过
$ sudo /etc/init.d/networking restart