我在运行Debian 5.0的同一个子网上有两台机器。 他们使用相同的DNS(/etc/resolv.conf),他们路由到相同的网关(#route),他们有相同的iptables设置(#iptables -L)。 我可以从他们两个,ping到IP地址和主机名。 我可以运行#host www.google.com并获得相同的结果。 但问题是,在其中一个上,我无法控制或curl。
所以在机器1上一切正常,但在机器2(与机器1相同的设置),我不能wget或curl。
我得到的错误是:
# wget google.com --2009-10-20 16:38:36-- http://google.com/ Resolving google.com... failed: Name or service not known. wget: unable to resolve host address `google.com'
但是在机器1上,wget或curl并没有问题,并返回:
# wget google.com --2009-10-20 16:43:55-- http://google.com/ Resolving google.com... 74.125.53.100, 74.125.45.100, 74.125.67.100 Connecting to google.com|74.125.53.100|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently ... Saving to: `index.html.3'
等等。
我希望有人能在这里指出我正确的方向,以便我可以解决这个问题:)
检查你的/etc/nsswitch.conf
文件(或者Debian的相同文件,如果不是这样的话)。
host
和nslookup
总是做DNS查找。
但是其他应用程序首先会在NSS中查找其他命名系统(例如/etc/hosts
,NIS等)。 如果configuration了其他的东西,但不能正常工作,则可能会阻止应用程序尝试DNS。
感谢您的答案,你们!
这是nsswitch.conf文件。 我从教程中设置了LDAP,告诉我在主机中使用这一行:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
当我将其更改为:
hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4
它工作没有问题。 所以我猜如果在文件或mdns4_minimal中没有findnsswitchconfiguration文件使它返回null,对不对?
谢谢你的帮助!
在机器上configuration了无效的代理是否有错误? 尝试这个:
# wget --no-proxy google.com
尝试
nslookup google.com
这样我们就可以看到你在两个盒子上使用的DNS服务器。
首先要尝试检查DNS是否正常工作。
# host google.com google.com has address 74.125.67.100 google.com has address 74.125.45.100 google.com has address 74.125.53.100
如果您没有得到该响应,请检查/etc/resolv.conf并find该文件中列出的名称服务器。 你能ping他们每个人吗?
尝试单独查询每个人:
# host google.com 12.34.56.78
你能解决另一个主机?
我有同样的问题,但旁边更改/etc/nsswitch.conf
:
hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4
我还必须更改名称服务器:
更改/etc/resolv.conf
以便它指向谷歌名称服务器。 networkingpipe理员添加的不适合我。
# RED 2013-03-31 nameserver 8.8.8.8 nameserver 8.8.4.4
我认为你不能直接改变/etc/resolv.conf。
你需要创build一个/etc/resolv.conf.head文件来完成。