Unable to ping mysite.myhost from Android but works OK from Mac/Raspian/Debian machines

I am getting a ping failure from an Android terminal (Termux) but it works OK from my other computers on the LAN. There are some similar posts but nothing quite like what I see.

This is the set up I have:

  • A registered site = 'kinshamservers.org.uk'. I can ping this from all my computers and get the expected IP - OK
  • Pihole on RPI is my DHCP server and DNS
  • Local LAN with a variety of devices using Android/iOS/MacOS/Raspian/Debian10 and various flavors of Linux in embedded devices
  • A records on Pihole pointing to local devices and computers. I can ping all these from all my computers (Android/Mac/Raspian/Debian10) - OK
  • CNAME record on Pihole = testy.kinshamservers.org.uk pointing to kinshamservers.org.uk. I can ping testy... from everything except Android where I get "unknown host" resonse - NOTOK. This is the error that puzzles me.

Diagnostics
dig returns a correct response when executed on all my computers, e.g. from MAC
chriswilkinson@MacBook ~ % dig kinshamservers.org.uk
; <<>> DiG 9.10.6 <<>> kinshamservers.org.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29896
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;kinshamservers.org.uk. IN A

;; ANSWER SECTION:
kinshamservers.org.uk. 1205 IN A 84.39.117.57 <<<< correct

;; Query time: 81 msec
;; SERVER: 192.168.1.73#53(192.168.1.73) <<<< correct = RPI DNS
;; WHEN: Wed Aug 04 14:30:25 BST 2021
;; MSG SIZE rcvd: 66

dig returns the correct response from computers other than Android, again e.g. from MAC
chriswilkinson@MacBook ~ % dig testy.kinshamservers.org.uk
; <<>> DiG 9.10.6 <<>> testy.kinshamservers.org.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2314
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;testy.kinshamservers.org.uk. IN A

;; ANSWER SECTION:
testy.kinshamservers.org.uk. 2 IN CNAME kinshamservers.org.uk.
kinshamservers.org.uk. 936 IN A 84.39.117.57

;; Query time: 165 msec
;; SERVER: 192.168.1.73#53(192.168.1.73)
;; WHEN: Wed Aug 04 14:34:54 BST 2021
;; MSG SIZE rcvd: 107

dig is not giving the expected answer when executed in a Termux Android terminal.
$ dig testy.kinshamservers.org.uk
; <<>> DiG 9.16.11 <<>> testy.kinshamservers.org.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 41361
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;testy.kinshamservers.org.uk. IN A

;; AUTHORITY SECTION:
kinshamservers.org.uk. 599 IN SOA ns11.domaincontrol.com. dns.jomax.net. 2021080216 28800 7200 604800 600

;; Query time: 90 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed Aug 04 14:53:46 BST 2021
;; MSG SIZE rcvd: 127

So that seems to comport with the ping error.

  • If I specify Pihole as the DNS then I get a correct response
    $dig @192.168.1.73 testy.kinshamservers.org.uk
    ; <<>> DiG 9.16.11 <<>> @192.168.1.73 testy.kinshamservers.org.uk
    ; (1 server found)
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34358
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;testy.kinshamservers.org.uk. IN A

;; ANSWER SECTION:
testy.kinshamservers.org.uk. 2 IN CNAME kinshamservers.org.uk.

;; Query time: 30 msec
;; SERVER: 192.168.1.73#53(192.168.1.73)
;; WHEN: Wed Aug 04 16:02:15 BST 2021
;; MSG SIZE rcvd: 91

I tried setting Android to static IP with DNS pointing to Pihole but that didn't make any difference - same issue. I've reverted to DHCP now so it should be getting its DNS from Pihole DHCP.

All this seems to suggest that there is nothing wrong with Pihole configuration but that Android has some issue. Is there something different about Android that would explain this failure?

I recall that the termux app in Android uses Google DNS, not the specified network DNS.

2 Likes

A further observation is that if ping testy.kinshamservers.org.uk doesn't work, then do ping kinshamservers.org.uk and then again testy.kinshamservers.org.uk and it does work??

Also when ping testy.kinshamservers.org.uk doesn't work, the browser can't find the site either. Doing the above double take gets the site accessible again. This doesn't last however.

I tried the Termius and Juice terminals on Android with the same result. Doesn't seem like a Termux issue.

As jfb has suggested:
Bottom line is that Android terminal apps are unreliable when it comes to local DNS resolution (reason might be that constraints of Android's sandbox model for apps are preventing them from accessing actual DNS parameters, but I'm just guessing wildly here).

If you have a web server running on one of your local domain hosts, I guess you'll find that accessing web pages served from that local server would render fine in a browser, while terminal pings would still fail. This should also be reflected in Pi-hole's Query Log accordingly.

Unfortunately that is not the case. Not only does ping fail, but the server on my local domain is also inaccessible from an Android browser. The Pihole status log shows "unknown (0)" when the browser attempts to access the site. In contrast, accessing the same site from a Mac browser shows that the DNS query is OK, forwarded to Google (my default upstream DNS setting). It appears that Android is unable to direct DNS queries to a local DNS.

One other thing I tried is to set Andoid with a static IP. This let's me specify Pihole as the DNS. I actually have two spaces for DNS and I set Pihole in both. This appears to be working, at least for now. I'll let it run a while. I had tried this previously and it didn't work but that maybe because I only filled one of the two DNS fields.

Yes it is.
Check who is answering your dig in Termux:

Termux runs in a different environment/jail/chroot or whatever.
The other apps should still honor the DNS settings in Android though.
Could install the "Network info" app end check Android DNS IP's configured for WiFi.

3 Likes

After some further testing, I found that setting Android with a static IP does not help. After a while my local sites become inaccessible and do not respond to pings.

The solution I finally came up with is to move all my Pihole CNAME records to the hostname registrar DNS config, GoDaddy in my case. Pihole is now used just for local hostname resolution and forwarding DNS requests upstream.

I have reverted Android to DHCP. It all appears to be working correctly now. This works on the local LAN, over VPN and cellular connections for all flavours of OS that I use.

The light bulb moment was realising that I can address my local sites as mysite.mydomain:port and utilise the name-port based virtual server capability of Apache.

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