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)
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.
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: ]
Grant Tasker WRITE_SECURE_SETTINGS permissions via ADB with following command:
adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
- To set Private DNS to Off instead of 'Automatic' use the value 'Off' instead of 'opportunistic'.
- Tested with Android 11, Samsung S10E, no root.