Mobile app dns problem

Hello,

I installed the NextCloud server on a computer at home and it’s working fine. I also set up a DNS server. I defined my NextCloud server’s local IP address with a network record called drive.example.com. My computer at home connects to the drive.example.com NextCloud server via the local IP address. However, when I connect my phone to my home Wi-Fi network and open the app on my phone, it connects to the drive.example.com server’s public IP address. In short, when my phone is connected to my home Wi-Fi, it connects to the public IP address of my NextCloud server, not the local IP address. In other words, while connected to my home Wi-Fi, my phone connects to my home NextCloud server over the internet. How can I fix this? It’s as if the NextCloud mobile app is sending requests to the DNS servers within itself.

You are a funny person. You’re asking for help with your mobile phone, but you don’t tell us what operating system it’s using.

Do you think we have crystal balls to look for the OS of your phone?

Hello, I’m using Android 12.

One major option may be you face this problem is because you have defined a private DNS in Settings → Network & Internet → Private DNS.

That would force Android to use the external DNS-Server you have defined there and not the local one in your LAN / WiFi.

I know this and my private dns settings are off.

Connect your Phone with your WiFi. Touch the gear icon next to you home WiFi. Scroll down to DNS.

There you see what DNS-Server IP was send by DHCP (IPv4) and SLAAC (IPv6) to your phone. Are both the local once of your LAN?

IF so check if you have any VPN’s active on your phone.

Depending on the brand and model of your router you might be able to set the private IP address of Nextcloud to your domain in the DNS-settings or configure “DNS-rebind” to forward the call to the local IP address of your Nextcloud instande.

Modifying the DNS settings on your mobile device may lead to unexpected behavior, if you use WLAN or WWAN from outside.

The DNS server of my phone connected to Wi-Fi is defined as my local DNS and I do not use VPN.

My home network and Wi-Fi network have my own DNS server configuration, and the DNS server configuration is stored on this DNS server.

The router’s DHCP role scope option is DNS server 192.168.1.2, and the NextCloud server IP address is 192.168.1.3. There’s no manually entered DNS on my phone. It receives an IP address from DHCP (the router), and my phone doesn’t have a VPN installed. The DNS server is AdGuard DNS record drive.example.com 192.168.1.3. In the DNS logs, check that the phone’s NextCloud app isn’t requesting the address Drive.example.com. When I access drive.example.com from my phone’s browser, I can see the logs from my AdGuard DNS server.

if the browser uses the right local IP but some other app uses public IP after switch from internet to local LAN I could imagine DNS cache is in place - look at TTL of the public DNS record and reduce it to lower value so the client switches to local IP more quickly

Disable “mobile data”, otherwise the device gets the public IP-address of the Nextcloud server.
Also check, whether the local DNS server also has the IPv6 address configured.

1 Like

Hello, the TTL for the DNS record is 5 minutes. I’ve been connected to Wi-Fi for two days, but it’s still resolving the public IP. I’ll try disconnecting my mobile phone and see if that resolves.