Let say on my home Wifi, I want to use DNS server "X" and on work WiFI, I want to use another DNS-server: "Y", on cellular a server "Z" and so on. Is this possible to do this automatically? (Preferably without root) There seems to be loads of "DNS-apps" on play store, but I can't find any that do this. (have not tried them all)

  • If you disable the "private DNS" feature of Android you should get the matching DNS server for each connection automatically pushed as part of the IP information via DHCP.
    – Robert
    Jul 16, 2021 at 9:55
  • I don't see how this helps? I know what DNS servers I want to use.
    – droidgren
    Jul 16, 2021 at 10:38
  • So you don't want the standard DNS servers, but use special other DNS servers but for each connection a different one. That was not obvious from your question.
    – Robert
    Jul 16, 2021 at 11:14
  • Exactly..I really tried to be as clear as possible but I guess I wasn't.
    – droidgren
    Jul 17, 2021 at 7:47

2 Answers 2


The solution below will set Private DNS to "Automatic" on SSID: 'SSID-1' and 'SSID-2' Everything else will set Private DNS to your entered Private DNS hostname in settings.

  1. Install Tasker.

  2. Set up tasker as follow: (Change SSID-1/SSID2 to your name)

     Profile: AutoPrivateDNS
             State: Wifi Connected [ SSID:SSID-1/SSID-2 MAC:* IP:* Active:Any ]
         Enter: Anon
             A1: Custom Setting [ Type:Global Name:private_dns_mode Value:opportunistic Use Root:Off Read Setting To: ]
         Exit: Anon
             A1: Custom Setting [ Type:Global Name:private_dns_mode Value:hostname Use Root:Off Read Setting To: ]
  3. Grant Tasker WRITE_SECURE_SETTINGS permissions via ADB with following command:

adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS

  1. To set Private DNS to Off instead of 'Automatic' use the value 'Off' instead of 'opportunistic'.
  2. Tested with Android 11, Samsung S10E, no root.

You can setup a Tasker profile that is based on either a location or a WiFi network to trigger the task. Set the task to change the custom setting for private DNS with the hostname dependent on which network you are on.

  • 1
    Thanks, This worked fine! I posted a more detailed answer below how to do it.
    – droidgren
    Jul 20, 2021 at 8:11

You must log in to answer this question.

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