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).
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
On non-rooted devices it's possible to use
VpnService API of Android to capture all DNS traffic. That's how apps like 126.96.36.199 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.
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.