Use hostname instead of IP as DNS server

Hello,

I have installed Pi-hole successfully in Raspberry-pi. Now I want to use it in Android Phone. But It ask for hostname. So using duckdns I have created a domain that points to my pi hole IP address. So in my private network It will work.

But It's not working. I need to Implement somthing like "dns.google" as they mentioned here for Android
https://developers.google.com/speed/public-dns/docs/using#android

What's wrong I'm doing here. Let me know.

Thanks

This is what I would like to do also - My ISP supplies a dynamic IP Address so if I use this as my DNS externally I'm not at home it will randomly stop working as my IP Changes :confused: If you find a solution to this please could you let me know? Thanks!

I think I understand what you're trying to do and it's actually a little bit tricky.

At home on your LAN your Android phone is connected over WiFi will get a IP-adress and DNS server information from your WiFi router.

When you are outside of your home the phone's cellular network will assign different IP and DNS servers to your phone.

I'm assuming you want your phone to use your pi-hole as DNS server when on the cellular network. However, if your pi-hole is behind your router at home it is not accessible from outside. When your are connected to your cellular network there is no way for your phone to "talk" to the pi-hole, your phone can not reach it.

You may have a public IP-adress, but that IP is your router's, the pi-hole is behind the router and not accessible.

You can open up your router and allow access to the pi-hole from outside - this is not a good idea since the pihole responds to any DNS request without authentication. It will be found and used by hackers creating denial-of-service attacks.

There are a number of ways to achieve what you want to do - setting up a VPN server at home or using the ZeroTier network, but they are a little tricky to set up and debug..

I take it from your description that you are trying to set Pi-hole as your Android's custom DNS.

If your Android is connected to your home network via WiFi, there is no need to use this Android option, as you can configure your router to use or distribute Pi-hole as DNS server, or have Pi-hole act as DHCP server doing the latter in case your router doesn't cooperate.

The fact that your Android requires a hostname for custom DNS configuration also suggests you are on Android 9 or higher, where setting a custom DNS server is restricted to those DNS servers supporting DNS-over-TLS, and you no longer can configure individual DNS servers for specific networks.

This wouldn't affect your home network, as that advertises Pi-hole as DNS server to your Android.
However, you wouldn't be able to access Pi-hole via your carrier's mobile data connections - which is perfectly normal. regardless whether you would use an IP address or a hostname to access your Pi-hole, since Pi-hole is operating in your home network only.

Any steps you take to allow indiscriminate access to Pi-hole from public networks (as your carrier's mobile data net) will turn your Pi-hole into an open resolver, which poses a potential threat for all Internet users, e.g. by serving as a multiplier in a DNS Amplification attack.

The Pi-hole team strongly discourages Pi-hole’s usage as an open resolver , and we won't provide support in that case.

As @cmgeek has pointed out, VPN access is a much better and safer way to use Pi-hole as your mobile device's DNS server when connected to public networks. There's a wealth of choices available when picking a VPN for yourself, including Pi-hole's guide on Pi-hole and OpenVPN.
In such an environment, your Android device would join the VPN and again receive Pi-hole as DNS server via DHCP, so no need to use Android's custom DNS option.