Custom DNS On Cellular Networks

Android does not offer a way to change the DNS' on cellular networks. There are some apps which allow you to do this, even on newer versions of Android. However, I decided to just use Tasker for it, as I did not want to install another app that runs in the background.

We need two different profiles for this to work. One is to set the DNS values when the device completes booting. The other profile is to set the custom DNS values when WiFi is turned off, and mobile data is turned on. This is required as DNS values seem to be reset, every time WiFi is turned off and mobile data is turned on.

You need a rooted device for this!

1. Add profile -> Event -> System -> Device Boot
2. Add profile -> Event -> Variable -> %WIFI is off
3. Add task and name it -> Add Action -> Code -> Run Shell -> Use Root -> Paste the following into Command field

setprop net.dns1 8.8.8.8 ; setprop net.dns2 8.8.4.4 ; setprop net.rmnet0.dns1 8.8.8.8 ; setprop net.rmnet0.dns2 8.8.4.4

4. Add task to profiles created in both steps 1 and 2
5. Enable profiles created in steps 1 and 2

Note: You are free to substitute 8.8.8.8 and 8.8.4.4 with your own DNS servers. I am using Google Public DNS.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License