Pi.hole resolves, but I can't ping it, wat?

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

Expected Behaviour:

I should be able to ping pi.hole from a machine connected to my local network.

Actual Behaviour:

mella:~ ratkins$ host pi.hole
pi.hole has address 192.168.1.2
mella:~ ratkins$ ping pi.hole
ping: cannot resolve pi.hole: Unknown host
mella:~ ratkins$ ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=0.944 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=3.702 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=3.563 ms
^C
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.944/2.736/3.702/1.269 ms

Debug Token:

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

I’m using the DHCP server on my router, not the Pi Hole, but I really don’t understand how the above can be happening. host resolves the name to the correct IP address, I can ping the IP address, but if I ping the hostname it doesn’t resolve?! That doesn’t make any sense.

(Everything else works fine from the machine I’m attempting to send the ping from.)

Does a dig pi.hole return the right IP address?

Yup:

mella:~ ratkins$ dig pi.hole

; <<>> DiG 9.10.6 <<>> pi.hole
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49141
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;pi.hole.			IN	A

;; ANSWER SECTION:
pi.hole.		2	IN	A	192.168.1.2

;; Query time: 276 msec
;; SERVER: 192.168.1.2#53(192.168.1.2)
;; WHEN: Mon Aug 12 21:09:55 CEST 2019
;; MSG SIZE  rcvd: 52

What does the /etc/resolv.conf look like?

As it says, /etc/resolv.conf isn’t used on macOS (10.14.6, for reference) but it and the output of scutil --dns both look good:

mella:~ ratkins$ cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
nameserver 192.168.1.2
nameserver 1.1.1.1
mella:~ ratkins$ scutil --dns
DNS configuration

resolver #1
  nameserver[0] : 192.168.1.2
  nameserver[1] : 1.1.1.1
  if_index : 7 (en0)
  flags    : Request A records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)

resolver #2
  domain   : local
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300000

resolver #3
  domain   : 254.169.in-addr.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300200

resolver #4
  domain   : 8.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300400

resolver #5
  domain   : 9.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300600

resolver #6
  domain   : a.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300800

resolver #7
  domain   : b.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 301000

DNS configuration (for scoped queries)

resolver #1
  nameserver[0] : 192.168.1.2
  nameserver[1] : 1.1.1.1
  if_index : 7 (en0)
  flags    : Scoped, Request A records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)

And whaddayaknow, I just tried ping pi.hole again and it worked!

mella:~ ratkins$ ping pi.hole
PING pi.hole (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=146.118 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=192.368 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=1.151 ms
^C
--- pi.hole ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.151/113.212/192.368/81.458 ms

This is extremely odd. I guess something was cached somewhere and had to expire (I had changed the IP of the Pi Hole from .42 to .2 in the hours before I first posted.)

Sorry for the false alarm, but I promise the above output is cut and pasted directly from my terminal without me fiddling with it :slight_smile:.

You have 1.1.1.1 as a nameserver listed. There isn’t a “secondary” or “fallback” DNS server, both the listed servers will be used. When you ping and the name lookup fails that is because the client is asking 1.1.1.1 for the name instead of asking 192.168.1.2. 1.1.1.1 doesn’t know pi.hole so it fails.

:facepalm: I had that totally wrong then, I didn’t realise they round-robin them. Will fix that immediately. Many apologies for the derp.

1 Like