Where does Android get its DNS information when connected to Wi-Fi? I'm hosting a server on my LAN with a port exposed publicly by the router. myserver.mydomain.com is pointing to the static IP of my router. So I can access the server from the the internet.
To make myserver.mydomain.com work when connected to my LAN I added an entry to the DNS server of my router, so it redirects to the private IP address of the server. This works fine for most devices connected to my LAN, except for my Android phone, where myserver.mydomain.com still resolves to the public IP of my router, even when connected to my Wi-Fi. So I suspect android always uses google DNS servers or something.
When I'm out and about connecting to some random Wi-Fi network this seems like highly desirable behavior, but when at home this creates the said issue.
I know I could configure my own DNS servers on my phone but I don’t want to configure that manually each time I connect to my LAN.
What would be the best approach here? Maybe I need to set up local access to my server differently?
Thank you all for the comments. They helped me work it out.
I'm not 100% sure of the cause of the behavior. It stays even when I switch off 4G and restart the phone. In the post linked to by Irfan Latif it is suggested that Android favors IPv6 dns servers. That could be the cause since my network is IPv4 only.
But the hairpin NAT provided the solution. (Called NAT Reflection in pfSense) After enabling this, things started to work.