在Debian Linux中无法正确设置DNS?


10

我的网络上有一个静态 IP地址。

我可以ping通Google的服务器之一:

root@napajohn:~# ping 74.125.224.72
PING 74.125.224.72 (74.125.224.72) 56(84) bytes of data.
64 bytes from 74.125.224.72: icmp_req=2 ttl=49 time=76.5 ms
64 bytes from 74.125.224.72: icmp_req=3 ttl=49 time=75.6 ms
64 bytes from 74.125.224.72: icmp_req=4 ttl=49 time=76.6 ms
64 bytes from 74.125.224.72: icmp_req=5 ttl=49 time=76.6 ms

但是我无法解析任何主机名:

root@napajohn:~# ping www.google.com
ping: unknown host www.google.com

我应该注意,我在代理后面,但这不影响不解析名称。我也无法解析代理人的姓名。

这些是我的/ etc / hosts文件的内容:

root@napajohn:~# cat /etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.0.1 napadev

这些是我的/ etc / networks文件的内容:

root@napajohn:~# cat /etc/networks
default         0.0.0.0
loopback        127.0.0.0
link-local      169.254.0.0

这些是我的/ etc / network / interfaces文件的内容:

root@napajohn:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

#default bootstrap static address
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
        address 129.83.161.162
        netmask 255.255.255.0
        gateway 129.83.161.254

这是我的/etc/netswitch.conf文件的内容:

root@napajohn:~# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

各种命令的一些输出:

一:

root@napajohn:~# getent hosts
127.0.0.1       localhost
127.0.0.1       localhost ip6-localhost ip6-loopback
127.0.0.1       napadev

二:

root@napajohn:~# find / -name resolv*
/usr/lib/gcc/4.4.7/gcc-4.4.7/gcc/fortran/resolve.c
/usr/share/vim/vim72/syntax/resolv.vim

三:

root@napajohn:~# find / -name named.*
/usr/lib/gcc/4.4.7/gcc-4.4.7/gcc/testsuite/g++.dg/cpp0x/named.C
/usr/share/vim/vim72/syntax/named.vim

四:

root@napajohn:~# grep -riI dns /etc
/etc/insserv.conf:$named                +named +dnsmasq +lwresd +bind9 $network
/etc/lynx-cur/lynx.cfg:# until a valid Internet host is created, based on a successful DNS
/etc/lynx-cur/lynx.cfg:# no-proxy zones in the DNS domain name space.  If a tail substring of the
/etc/services:mdns              5353/tcp                        # Multicast DNS
/etc/services:mdns              5353/udp                        # Multicast DNS
/etc/udhcpd.conf:# as the dns option, they can be listed on the same line, or multiple
/etc/udhcpd.conf:opt    dns     192.168.10.2 192.168.10.10
/etc/udhcpd.conf:option dns     129.219.13.81   # appened to above DNS servers for a total of 3
/etc/udhcpd.conf:#opt dns
/etc/profile.d/napa_config.sh:#export NAPA_DNS='192.168.42.1'
/etc/ssl/certs/Verisign_Time_Stamping_Authority_CA.pem:/OB4naCTuQk9I1F/RMIUdNsKvsvJMDRAmD7Q1yUQgZS9B0+c1lQn3y6ov8uQjI11
/etc/ssl/certs/95750816.0:/OB4naCTuQk9I1F/RMIUdNsKvsvJMDRAmD7Q1yUQgZS9B0+c1lQn3y6ov8uQjI11
/etc/ssl/certs/a3896b44.0:9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ
/etc/ssl/certs/DigiCert_Assured_ID_Root_CA.pem:VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/
/etc/ssl/certs/69105f4f.0:VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/
/etc/ssl/certs/ca-certificates.crt:VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/
/etc/ssl/certs/ca-certificates.crt:9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ
/etc/ssl/certs/ca-certificates.crt:/OB4naCTuQk9I1F/RMIUdNsKvsvJMDRAmD7Q1yUQgZS9B0+c1lQn3y6ov8uQjI11
/etc/ssl/certs/Security_Communication_Root_CA.pem:9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ
/etc/ssl/certs/6f5d9899.0:VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/
/etc/ssl/certs/6f5d9899.0:9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ
/etc/ssl/certs/6f5d9899.0:/OB4naCTuQk9I1F/RMIUdNsKvsvJMDRAmD7Q1yUQgZS9B0+c1lQn3y6ov8uQjI11
/etc/ssh/ssh_config:#   GSSAPITrustDNS no
/etc/nsswitch.conf:hosts:          files dns

五:

root@napajohn:~# grep -riI name-server /etc
root@napajohn:~# grep -riI nameserver /etc
/etc/services:nameserver        42/tcp          name            # IEN 116

六:

root@napajohn:~# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:15:c9:28:e3:96
          inet addr:129.83.161.162  Bcast:129.83.161.255  Mask:255.255.255.0
          inet6 addr: fe80::215:c9ff:fe28:e396/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16863 errors:0 dropped:0 overruns:0 frame:0
          TX packets:128 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1586688 (1.5 MiB)  TX bytes:13557 (13.2 KiB)
          Interrupt:80

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:900 errors:0 dropped:0 overruns:0 frame:0
          TX packets:900 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:72008 (70.3 KiB)  TX bytes:72008 (70.3 KiB)

我花了几个小时试图找出导致此问题的潜在原因,但从到目前为止的阅读和尝试来看,一切似乎都很正常(因为人们在其他线程中建议的内容已经很好/已经存在于我的机器上),除了我没有 /etc/named.conf文件,也没有 /etc/resolv.conf文件。我可以创建它们(我什至不知道要放入什么?),但我认为这不能解决问题。有什么建议吗?

我在跑步:

root@napajohn:~# cat /etc/debian_version
6.0.3
root@napajohn:~# uname -a
Linux napajohn 2.6.34 #4 Mon Oct 31 16:41:13 EDT 2011 armv7l GNU/Linux

在strkol评论后编辑1:

root@napajohn:~# echo "nameserver 8.8.8.8" > /etc/resolv.conf
root@napajohn:~# ping www.google.com
ping: unknown host www.google.com

仍然没有骰子,但ping现在尝试了一段时间,然后放弃了,而不是立即输出“无法解析主机”

Answers:


10

您需要/etc/resolv.conf文件。它告诉服务器哪些域名服务器用作解析器。我怀疑您的服务器当前正在尝试使用其自身,并且您没有将名称配置为充当解析程序。

询问您的ISP或主机提供商,将哪些名称服务器用作解析器。如果所有其他方法均失败,则将以下内容放在/etc/resolv.conf中,这两个应该正常工作:

nameserver 208.67.220.220
nameserver 208.67.222.222

谢谢。这些名称服务器对我不起作用,但是您的答复使我在曾经连接到我们网络的另一台计算机上查看了该文件,并且发现该文件存在两个地址。我添加了这些,现在我可以访问DNS了。探针解决了!(双关语)
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.