I am learning about how Windows does name resolution and need to know how Android does it so an app will work on my Windows laptop and from my Android Phone.
Borrowing from a post on superuser.com, the normal resolution method on windows is as follows:
- The client checks to see if the name queried is its own.
- The client then searches a local Hosts file, a list of IP address and names stored on the local computer.
- Domain Name System (DNS) servers are queried.
- If the name is still not resolved, NetBIOS name resolution sequence is used as a backup. This order can be changed by configuring the NetBIOS node type of the client.
I use dnsmasq
to provide local DNS resolution so I can map my own made up hostnames to local LAN IP addresses. This also allows me to see, in the dnsmasq
log file, the DNS query that goes from the client to the DNS server. While testing the website from my phone I could swear using the URL address http://mywebsite
in a Chrome browser on the phone was loading the website and the dnsmasq
log showed just that unqualified name - mywebsite
- resolving to the desired local IP address the web server is at.
However that was a few days ago, now the dnsmasq
log always shows that the DHCP server DNS suffix [home] has been appended. So I see mywebsite.home
in the dnsmasq
log even though I used the URL address http://mywebsite
in the phones Chrome browser. I didn't change anything with the phone. It is still set up to get its IP address via DHCP, in practice it never changes.
So my questions are:
- How does Android OS resolve domain names to IP addresses - what things does it try and in what order?
- Any feedback on why Android seemed to be resolving the unqualified hostname in my browser originally without any DNS suffix being appended. But now the
[home]
suffix is always appended as reported in thednsmasq
log file.
Update 1
After some more testing I have again seen the scenario where the webpage http://mymovies
loads from the Android phone but the dnsmasq
log appears to show the name resolution happening on an unqualified domain name (bare hostname: mymovies
).
The x
's are my redacted routers public IP address.
Can anyone explain what dnsmasq
is doing here?
Starting from 02:07:22 it initially seems to try resolving the name mymovies.home
. This makes sense because the phones IP is dynamically allocated by the DHCP server and I can see on my laptop that the DHCP server sends the DNS suffix [home]
as the connection-specific DNS suffix so it must be doing the same to the phone I guess?
The reason why it fails here is because I do not have an entry for mymovies.home
in dnsmasq.conf
- I commented it out. I DO have an address entry for mymovies
in dnsmasq.conf
and that seems to be why it can resolve mymovies
to an IP address.
Is this a difference of name resolution in Android compared with Windows - that eventually Android OS WILL try to resolve an unqualified domain name (bare hostname) to an IP address?