I researched a way to filter sites using DNS Server on android phone, and that is to changed the phone's DNS Server, it worked for WiFi connection, but not for Data Connection, how would I Block/Filter Sites on Mobile Data Connection (Preferably using DNS Server).

  • I have not tried that (felt no need yet), but there's a list of Proxy apps for Android you might wish to check with.
    – Izzy
    Commented Jun 27, 2016 at 15:59

2 Answers 2


There are no settings to set DNS server with Mobile Data. An exception is Private DNS (DoT) on Android 9+. Also sometimes DNS leakage may occur with WiFi DNS settings e.g. if some app has hard-coded DNS server address. However with root access you can force redirect DNS queries to any specific server using iptables. See details in How does Android OS do DNS name resolution? and How to configure DNS properly?

Or you can edit /etc/hosts to blacklist commonly known ad domains using available hosts files like this one.

Or even better is to run a local DNS server on device to use features like pattern matching etc. dnscrypt-proxy, for instance, provides flexible options including encrypted DNS (DoH or DoT) which nullifies the possibility of ISP's eavesdropping on your DNS traffic. For setup instructions see How to fix SELinux errors when launching DNSCrypt as init.d script?

On non-rooted devices it's possible to use VpnService API of Android to capture all DNS traffic. That's how apps like and NetGuard work. Then the VPN app may use a custom hosts file before making queries to configured upstream DNS server. Virtual Hosts is an open-source app to achieve this.

  • Adguard with local DNS filtering is similar to what the OP is expecting. It works with custom DNS filtering and option for multiple DNS servers.
    – k1chy
    Commented Dec 15, 2019 at 16:50
  • @k1chy correct. Personally I use root solutions - simple and robust. AdGuard is a paid premium service, so it can provide hassle-free experience. But one may prefer to go with free open-source solutions if available, as Virtual Hosts is (there may possibly be others, I never used one). Both are based on VPN. There are a range of hosts files already available which can be merged and customized to allow or block certain domains. Plus AdGuard's public DNS servers can also be used in addition to local hosts. But they do caching, are slow and problematic e.g. with DDNS. Cloudflare is super fast Commented Dec 15, 2019 at 17:49

For this the phone has to be rooted and the mobile version of a ads-blocking HOSTS file can be used. Here is an example: http://free-software-for-android.github.io/AdAway/

For mobile data, the DNS server would be provided by the telco. You can remove the proxy provided in the APN used by the telco. See FAQ at above link.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .