dig works but ping does not resolve host

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?


Solution 1:

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.