Domain names not getting resolved when pinging but IP Address works

Please follow the below template, it will help us to help you!

Expected Behaviour:

If I do a ping google.com I expect to get a response.
If I do a ping 172.217.2.238 (which is what nslookup google.com gives me) I expect to get a response.

Actual Behaviour:

When using the domain name in a ping I get no response. I just have to cancel it out.
When I use the IP Address it works perfectly.

Debug Token:

https://tricorder.pi-hole.net/tsa4a0olky

From what device are you running these commands - from the Pi Linux terminal, or from a connected client? From the Pi, what is the output of dig google.com

Your debug log shows that Pi-Hole is running properly and resolving DNS queries:

*** [ DIAGNOSING ]: Name resolution (IPv4) using a random blocked domain and a known ad-serving domain
[✓] denisaslan97.000webhostapp.com is 0.0.0.0 via localhost (127.0.0.1)
[✓] denisaslan97.000webhostapp.com is 0.0.0.0 via Pi-hole (192.168.1.107)
[✓] doubleclick.com is 172.217.1.142 via a remote, public DNS server (8.8.8.8)

   [2019-06-21 18:34:19.875 1998] Imported 25697 queries from the long-term database
   [2019-06-21 18:34:19.876 1998]  -> Total DNS queries: 25697
   [2019-06-21 18:34:19.876 1998]  -> Cached DNS queries: 3382
   [2019-06-21 18:34:19.876 1998]  -> Forwarded DNS queries: 15499
   [2019-06-21 18:34:19.876 1998]  -> Exactly blocked DNS queries: 6816
   [2019-06-21 18:34:19.876 1998]  -> Unknown DNS queries: 0
   [2019-06-21 18:34:19.876 1998]  -> Unique domains: 1957
   [2019-06-21 18:34:19.876 1998]  -> Unique clients: 7
   [2019-06-21 18:34:19.876 1998]  -> Known forward destinations: 4

It's from a Pi terminal. Running it from a client works just fine.
Here's the dig google.com output (from the Pi terminal)

; <<>> DiG 9.10.3-P4-Raspbian <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40983
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;google.com. IN A

;; ANSWER SECTION:
google.com. 144 IN A 172.217.1.238

;; Query time: 25 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Jun 21 19:29:32 CDT 2019
;; MSG SIZE rcvd: 55

And you're right, everything seems to be working fine except this particular issue. The reason I'm concerned is doing a sudo apt-get update takes FOREVER and I think it may be related to not being able to resolve a host name from the terminal.

The dig output shows that you can resolve a hostname in the terminal. The dig went from the Pi, to Pi-Hole, to the Pi-Hole upstream resolver and back to the Pi terminal, and provided the IP of the requested domain.

I see what you're saying but I don't understand this output:

pi@raspberrypi:~ $ nslookup google.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
Name: google.com
Address: 172.217.12.46

pi@raspberrypi:~ $ ping google.com
PING google.com(dfw25s27-in-x0e.1e100.net (2607:f8b0:4000:814::200e)) 56 data bytes
^C
--- google.com ping statistics ---
10 packets transmitted, 0 received, 100% packet loss, time 9370ms

pi@raspberrypi:~ $ ping 172.217.12.46
PING 172.217.12.46 (172.217.12.46) 56(84) bytes of data.
64 bytes from 172.217.12.46: icmp_seq=1 ttl=54 time=16.6 ms
64 bytes from 172.217.12.46: icmp_seq=2 ttl=54 time=28.6 ms
64 bytes from 172.217.12.46: icmp_seq=3 ttl=54 time=17.9 ms
64 bytes from 172.217.12.46: icmp_seq=4 ttl=54 time=19.5 ms
64 bytes from 172.217.12.46: icmp_seq=5 ttl=54 time=20.0 ms
64 bytes from 172.217.12.46: icmp_seq=6 ttl=54 time=18.6 ms
^C
--- 172.217.12.46 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5008ms
rtt min/avg/max/mdev = 16.670/20.258/28.640/3.903 ms

That is odd. I'm not a ping expert, but the output on my Pi is different than yours. Your's appears to be looking for the IPv6 address, not the IPv4. Here is my output for the same ping:

ping -c5 google.com
PING google.com (172.217.4.78) 56(84) bytes of data.
64 bytes from lga15s47-in-f78.1e100.net (172.217.4.78): icmp_seq=1 ttl=252 time=20.3 ms
64 bytes from lga15s47-in-f78.1e100.net (172.217.4.78): icmp_seq=2 ttl=252 time=24.9 ms
64 bytes from lga15s47-in-f78.1e100.net (172.217.4.78): icmp_seq=3 ttl=252 time=21.1 ms
64 bytes from lga15s47-in-f78.1e100.net (172.217.4.78): icmp_seq=4 ttl=252 time=18.4 ms
64 bytes from lga15s47-in-f78.1e100.net (172.217.4.78): icmp_seq=5 ttl=252 time=25.9 ms
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4003ms
rtt min/avg/max/mdev = 18.446/22.154/25.952/2.831 ms

Try ping -4 -c5 google.com to force IPv4.

Well that worked like a charm! So I was wondering if there was something wrong with IPv6 based on the output of the diagnostic run, specifically the 2 sections:

1st -

*** [ DIAGNOSING ]: Networking
[✓] IPv4 address(es) bound to the eth0 interface:
192.168.1.107/24 matches the IP found in /etc/pihole/setupVars.conf

[✓] IPv6 address(es) bound to the eth0 interface:
2605:6000:1000:452:7047:5f5d:183c:cf4 does not match the IP found in /etc/pihole/setupVars.conf (Use IPv6 ULA addresses for Pi-hole)
fe80::404f:bc8f:6793:38f does not match the IP found in /etc/pihole/setupVars.conf (Use IPv6 ULA addresses for Pi-hole)

^ Please note that you may have more than one IP address listed.
As long as one of them is green, and it matches what is in /etc/pihole/setupVars.conf, there is no need for concern.

The link to the FAQ is for an issue that sometimes occurs when the IPv6 address changes, which is why we check for it.

And the second section shows again IPv4 works but IPv6 has some issue
2nd -

*** [ DIAGNOSING ]: Name resolution (IPv4) using a random blocked domain and a known ad-serving domain
[✓] crystalxxxmovies.com is 0.0.0.0 via localhost (127.0.0.1)
[✓] crystalxxxmovies.com is 0.0.0.0 via Pi-hole (192.168.1.107)
[✓] doubleclick.com is 216.58.194.46 via a remote, public DNS server (8.8.8.8)

*** [ DIAGNOSING ]: Name resolution (IPv6) using a random blocked domain and a known ad-serving domain
[✓] www.cam4.fr is :: via localhost (::1)
[✗] Failed to resolve www.cam4.fr via Pi-hole (2605:6000:1000:452:b02a:25c1:ef1d:26d0)
[✗] Failed to resolve doubleclick.com via a remote, public DNS server (2001:4860:4860::8888)

So not sure what's wrong with my IPv6 resolving but I think that's the root of it all.

If you don't need IPv6 on your network, my advice is to disable it and simplify your network. Turn it off on the router, clients, etc.

If you want to keep IPv6 active, review the link that appears in the debug log.

I'll definitely disable it if it keeps causing me problems....because now today I can ping google.com from the Pi no problem. Very bizarre.

Thanks very much for your help @jfb. You've helped me poke around and learn a few more things about all this stuff.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.