1

I'd like to know which name servers are asked for a name, when I try to connect to a local device by name. Is it possible? I have a local DNS, which mostly works fine, but sometimes not.

For example, I can ping web.home.myname (myname=an own TLD, not a real one), or I can access this site from Android browsers if I'm connected to my Wifi. But can't when I'm connected to LAN via my own VPN, although the OpenVpn server pushes DNS settings to clients.

I'd like to see what's happens when I'm using VPN, but every DNS tools are using Google's DNS, instead of local server. Even if I'm connected to my Wifi (when I can access lan devices by name).


I'm trying to explain by real examples.

I have an Asus router with stock firmware, which acts as router, Wifi AP, DHCP server, DNS forwarder, firewall, OpenVpn server and PPPOE client. I have a server with many docker containers, including a container which runs dnsmasq. It is my main DNS, this is the only one, which can resolve the local domain names. I've configured DHCP on the router, to send the container's IP to clients as DNS server.

When my mobile connects to the AP, all apps run on this device, can access local devices by name. Because of it, I think, Android is able to use my own DNS server instead of Google's.

But... when I connect to the OpenVPN server (from the Internet), which runs on the router, I can access LAN devices by IP address, but not by name (with 3rd party firmware it works fine).

The VPN server has been configured to push the DNS settings to the clients but it doesn't work.

That's why I'd like to see, how are the names resolved, which DNS servers are asked when an app tries to access devices by name. The tried tools connect directly to 8.8.8.8, but the browsers and programs in termux app aren't, because they can access lan devices by name if the mobile is connected to the Wifi.

Ps: the mobile isn't rooted

Izzy
  • 91,166
  • 73
  • 343
  • 943
  • I read your question twice but can't understand what you are asking. Can you rephrase it? – Irfan Latif Jul 30 '20 at 06:29
  • With stock Android, those Google servers are unfortunately always the default even when on WiFi (where you usually get a DNS server assigned via DHCP, but then the Google one is used as "secondary" at least). If your device is rooted, you can override that e.g. using a custom script in AFWall+ (rewriting any packages on port 53 to the name server of your choice, depending on which network you're connected to). – Izzy Jul 30 '20 at 06:40
  • 2
    @Izzy also possible without root using VPN apps which intercept only DNS traffic. – Irfan Latif Jul 30 '20 at 07:13
  • @IrfanLatif theoretically yes – but in this case not: "when I'm connected to LAN via my own VPN". Only one VPN can be used at a time. So no separate VPN "which intercept only DNS traffic", sorry. – Izzy Jul 30 '20 at 11:16
  • @Izzy you must be correct. I wasn't able to understand OP's situation. – Irfan Latif Jul 30 '20 at 12:01
  • @IrfanLatif - O.K., I'll try to edit the question, and explain my problem by actual examples. Please look back a little bit later! – erc4cfcwefc Jul 30 '20 at 15:30
  • @erc4cfcwefc when using VPN, the VPN services tells your device which DNS servers to use. From your description, that server would be identical to your router, so it should actually work – if set up correctly. I'd check the setup of OpenVPN concerning DNS, maybe it's misconfigured and hands out some "external DNS server" instead of your local one's. But that would rather be a general networking question rather than an Android specific. – Izzy Jul 30 '20 at 17:19
  • @Izzy: yes, I know and with other fw (Merlin instead of stock fw) it works with the same settings. But this is just the reason, why I now asked, how to find out the real DNS server. Actually it is an older story, I often see that the name resolution doesn't work as I want, on my mobile – erc4cfcwefc Jul 30 '20 at 17:51
  • Just looking at the response of a DNS lookup in some cases is misleading (like in my case, where an iptables rule rewrites the request). I don't know which tools you've tried, but a network sniffer (packet analyzer) could help if you know how to work with it. I've never tried that myself, so I cannot point out details. Unfortunately, again such an app needs either root or VPN to collect the necessary details. So I'm afraid your situation requires a rooted device to test. – Izzy Jul 30 '20 at 19:15
  • To me your question seems more related to router and OpenVPN configuration but for Android part you may find some of my previous answers related to DNS helpful: https://android.stackexchange.com/a/220129/218526, https://android.stackexchange.com/a/205740/218526, https://android.stackexchange.com/a/218209/218526, https://android.stackexchange.com/a/215878/218526 – Irfan Latif Aug 03 '20 at 07:58
  • @IrfanLatif: the origin of the question is a router bug (Yes, I know, it is a bug in the fw). But the question is: how can I find out, which DNS servers asked by an android app when it try to resolve a host name. (packet sniffers aren't help, because they need a rooted device AFAIK) – erc4cfcwefc Aug 03 '20 at 16:29

0 Answers0