我怎么可能做主机查找而不是卷曲?

Dan*_*inn 24 domain-name-system wifi curl

有没有人见过这个?请注意,这不仅发生在 google.com 上,而且发生在我尝试的每个域中。这是一个无线连接 (WEP),但我不确定这有什么关系:

$ curl -v google.com
# This takes about 60s to return
* getaddrinfo(3) failed for google.com:80
* Couldn't resolve host 'google.com'
* Closing connection #0
curl: (6) Couldn't resolve host 'google.com'

$ wget google.com
--2011-11-28 14:44:08--  http://google.com/
Resolving google.com... failed: Name or service not known.
wget: unable to resolve host address `google.com'

$ ping google.com
PING google.com (209.85.148.147) 56(84) bytes of data.
64 bytes from fra07s07-in-f147.1e100.net (209.85.148.147): icmp_req=2 ttl=54 time=136 ms
64 bytes from fra07s07-in-f147.1e100.net (209.85.148.147): icmp_req=3 ttl=54 time=34.0 ms
64 bytes from fra07s07-in-f147.1e100.net (209.85.148.147): icmp_req=4 ttl=54 time=34.3 ms
64 bytes from fra07s07-in-f147.1e100.net (209.85.148.147): icmp_req=5 ttl=54 time=42.5 ms
64 bytes from fra07s07-in-f147.1e100.net (209.85.148.147): icmp_req=6 ttl=54 time=44.7 ms
64 bytes from fra07s07-in-f147.1e100.net (209.85.148.147): icmp_req=7 ttl=54 time=34.5 ms
^C
--- google.com ping statistics ---
8 packets transmitted, 6 received, 25% packet loss, time 7007ms
rtt min/avg/max/mdev = 34.063/54.376/136.026/36.758 ms


$ host google.com
google.com has address 209.85.148.106
google.com has address 209.85.148.147
google.com has address 209.85.148.99
google.com has address 209.85.148.103
google.com has address 209.85.148.104
google.com has address 209.85.148.105
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.

$ host google.com 192.168.1.201
Using domain server:
Name: 192.168.1.201
Address: 192.168.1.201#53
Aliases: 

google.com has address 209.85.148.103
google.com has address 209.85.148.104
google.com has address 209.85.148.105
google.com has address 209.85.148.106
google.com has address 209.85.148.147
google.com has address 209.85.148.99
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.

$ cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.1.201

$ cat /etc/hosts
127.0.0.1       localhost
::1             localhost

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG        0 0          0 wlan0
127.0.0.0       127.0.0.1       255.0.0.0       UG        0 0          0 lo
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0
Run Code Online (Sandbox Code Playgroud)

基本上任何应用程序,包括 Firefox,都无法进行名称查找。更重要的是,如果我将 wifi 离线并插入以太网电缆,一切都很好。

小智 9

使用这个:https : //www.centos.org/modules/newbb/viewtopic.php?topic_id=39343

我找到了一个帮助我排除故障的关键命令:

[root@localhost ~]# wget -6 URL 失败

[root@localhost ~]# wget -4 URL 有效

这与导致某些实用程序出现问题的默认 ipv6 堆栈有关。禁用ipv6来解决。


Jan*_*nen 8

也许你有一些非常奇怪和限制性的 SELinux(或 grsecurity...)规则?

如果没有,请尝试strace -o /tmp/wtf -fF curl -v google.com/tmp/wtf输出文件中找出发生了什么。


Mad*_*ter 7

检查您的/etc/nsswitch.conf. 如果这hosts条线说的是

hosts:      files dns
Run Code Online (Sandbox Code Playgroud)

我和你一样困惑。但如果它说类似的话

hosts:      files
Run Code Online (Sandbox Code Playgroud)

那么 DNS 正在工作的事实(请参阅host命令的输出)将无助于 curl,它通过标准操作系统库进行名称解析,已被告知不要使用 DNS。

  • 在我的主机线上有更多的东西。“dns”列在“[NOTFOUND=return]”之后,据我所知,这导致系统在检查配置的DNS服务器之前返回not found!将“dns”移至未找到的东西修复我的系统之前(必须重新启动)。 (2认同)

小智 5

我遇到了同样的问题 - 主机,nslookup 解析正常,curl - 不能在相同的主机名上。

在 tcpdumping 通信之后,我发现curl 尝试建立到 DNS 端口的 TCP(除了 UDP)连接,该端口在我的路由器中被关闭。启用 tcp 端口 53 后,curl 开始完美工作。

另一个奇怪的事情是,如果 dns 服务器是常规绑定安装,则不会出现此问题。如果我使用嵌入到路由器 DNS 服务器中的功能,curl 会突然尝试使用 TCP 端口,即使它已经在 2 毫秒之前通过 UDP 收到了(!)应答。我想这是错误。