大网数据广告活动
服务器运维问答

dig works but ping does not resolve host

· 52CE 我爱测

I've configured the DNS settings for a host ( admin.example-preprod.foobar.it with IP 100.100.100.100 ) but it does not resolve from every server I try (it does for some). For example, I'm on a server which uses the following 3 D…

问题原文

原帖链接 · cherouvim · CC BY-SA 3.0

I've configured the DNS settings for a host (admin.example-preprod.foobar.it with IP 100.100.100.100) but it does not resolve from every server I try (it does for some).

For example, I'm on a server which uses the following 3 DNS servers:

foobar@server:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 200.200.200.1
nameserver 200.200.200.2
nameserver 200.200.200.3

dig works for all of them.

first:

foobar@server:~$ dig admin.example-preprod.foobar.it @200.200.200.1

; <<>> DiG 9.9.5-3ubuntu0.7-Ubuntu <<>> admin.example-preprod.foobar.it @200.200.200.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6540
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 2
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;admin.example-preprod.foobar.it.        IN      A

;; ANSWER SECTION:
admin.example-preprod.foobar.it. 86400 IN A      100.100.100.100

;; AUTHORITY SECTION:
foobar.it.               86400   IN      NS      qwert.foobar.it.
foobar.it.               86400   IN      NS      ns0.xname.org.
foobar.it.               86400   IN      NS      ns1.xname.org.

;; ADDITIONAL SECTION:
qwert.foobar.it.         86400   IN      A       200.200.200.1

;; Query time: 46 msec
;; SERVER: 200.200.200.1#53(200.200.200.1)
;; WHEN: Fri Nov 04 10:35:46 EET 2016
;; MSG SIZE  rcvd: 156

second:

foobar@server:~$ dig admin.example-preprod.foobar.it @200.200.200.2

; <<>> DiG 9.9.5-3ubuntu0.7-Ubuntu <<>> admin.example-preprod.foobar.it @200.200.200.2
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 40127
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;admin.example-preprod.foobar.it.        IN      A

;; AUTHORITY SECTION:
foobar.it.               85817   IN      SOA     qwert.foobar.it. webmaster.foobar.it. 2016092901 10800 900 1814400 10800

;; Query time: 3 msec
;; SERVER: 200.200.200.2#53(200.200.200.2)
;; WHEN: Fri Nov 04 10:36:05 EET 2016
;; MSG SIZE  rcvd: 111

third:

foobar@server:~$ dig admin.example-preprod.foobar.it @200.200.200.3

; <<>> DiG 9.9.5-3ubuntu0.7-Ubuntu <<>> admin.example-preprod.foobar.it @200.200.200.3
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2392
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;admin.example-preprod.foobar.it.        IN      A

;; ANSWER SECTION:
admin.example-preprod.foobar.it. 86400 IN A      100.100.100.100

;; AUTHORITY SECTION:
foobar.it.               86400   IN      NS      qwert.foobar.it.
foobar.it.               86400   IN      NS      ns1.xname.org.
foobar.it.               86400   IN      NS      ns0.xname.org.

;; ADDITIONAL SECTION:
qwert.foobar.it.         81845   IN      A       200.200.200.1

;; Query time: 2309 msec
;; SERVER: 200.200.200.3#53(200.200.200.3)
;; WHEN: Fri Nov 04 10:35:56 EET 2016
;; MSG SIZE  rcvd: 156

but then, when I try to ping it gives me unknown host:

foobar@server:~$ ping admin.example-preprod.foobar.it
ping: unknown host admin.example-preprod.foobar.it

How is that possible and where should I look at to solve the problem?

已采纳解答

原帖链接 · James Yale · CC BY-SA 3.0

dig doesn't work for all of them - your second nameserver (200.200.200.2 in your example) isn't resolving the record.

The Linux resolver randomises between entries in resolv.conf by default and I'd guess your ping has hit the failing resolver.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。