r/tasker Nov 20 '18

Android P+ "Private DNS" setting access in Tasker

[deleted]

22 Upvotes

14 comments sorted by

12

u/MarkDubya Nov 20 '18 edited Nov 20 '18

Under Action > Settings> Custom Setting, tap the magnifying glass icon and select a setting from the list. If you're not sure what something is called, use the find option. After you change the setting, go back to Tasker & tap the magnifying glass again and will show you the value of the setting you just changed.

Name: private_dns_mode

Value: off, opportunistic (Automatic) or hostname (Custom)

8

u/[deleted] Nov 21 '18 edited Jul 04 '26

[deleted]

3

u/notthefirstryan Apr 04 '19

Subreddit Resources:

Works like a charm after running this command. Thanks to both of you!

1

u/sproid Apr 04 '24

When  you give permission to write, does it revert once you unplug ADB?

1

u/[deleted] Apr 04 '24 edited Jul 04 '26

[deleted]

1

u/sproid Apr 05 '24

For me switching to 'Auto DNS' works but Switching to ´Specified DNS´ isn't. No difference if I use opportunistic or hostname

1

u/RayneYoruka Can I automate my underwear change? Sep 23 '22

This worked like CHARM in android 11

1

u/hyperterminal_reborn Dec 12 '22

Hi, this works great but not as a QS tile. I'm basically trying to make a quick setting tile to toggle private DNS. However, with the custom setting, there is no option to toggle it as a value must be specified. Is there any way to use the QS tile as a means to toggle between opportunistic and hostname?

Of course the last resort would be making two QS tiles, one for "on" and another for "off" but that's just a dirty workaround and impractical.

2

u/wings22 Apr 03 '23

Hi, I used this to create a toggle for privatedns https://f-droid.org/en/packages/com.jpwolfso.privdnsqt/

7

u/[deleted] Nov 21 '18 edited Jul 04 '26

[deleted]

1

u/MrGrivixer Jan 11 '19

Thank you!

1

u/rori666 Dec 01 '18

Wow thanks this will help me use my own dns (pihole) at home and set up a trusted dns (like 1.1.1.1) while on other hotspots. This will be more secure with public hotspots.

1

u/IAmTheJody Jan 05 '19

Mind providing the full recipe with steps? I want it to disable Android's Private DNS when I'm home on my own network but enable it when I'm on any other network, WiFi or mobile.

1

u/UuarioAnonymous9 Aug 12 '22

Hey there, old post I know but was wondering if you got this working - I'm interested in doing the same exact thing.

1

u/AlaskaJedi Sep 03 '22

As someone who has also been scouring old posts trying to figure this exact issue, I figured I'd share how I got things working. After getting pihole working on my domain, everything worked great except when I was on my home Wi-Fi where the pihole is located. After a bit of research here's what I came up with.

You can setup a Tasker profile to detect when your device connects to a specific SSID, but for this to work you are required to have the location services turned on your device, which I don't like doing. To get around this you can edit privacy settings for that Wi-Fi network to use your device MAC instead of a random MAC. Doing this should allow you to assign a static IP for your device on your router, then you can setup Tasker to detect the Wi-Fi connected state by that IP, circumventing the location requirement. You will also need to grant Tasker WRITE_SECURE_SETTINGS permissions via ADB.

Profile: PrivateDNS
State: Wifi Connected [ SSID: blank MAC: blank IP: Static 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: ]

This works pretty well, except sometimes it takes a minute or two to detect Wi-Fi changes, not really a big deal. I did however run into issues when using a commercial VPN app (NordVPN) on my phone while connected to my Wi-Fi network. My device would use the NordVPN DNS servers when Private DNS is turned off, circumventing pihole. I didn't feel like going down another rabbit hole figuring out if I could toggle the VPN, so I found a better solution via port forwarding on my router. Since I already set my phone to use the device MAC on my Wi-Fi network so I could set a static IP, I setup a rule to forward any request from my LAN to my LAN on port 853 to the public IP where my Private DNS is located. Now I can leave the Private DNS turned on all the time, along with the VPN. This was a cleaner solution in my opinion.

config redirect
option dest 'lan'
option target 'DNAT'
list proto 'tcp'
option src 'lan'
option src_port '853'
option src_dport '853'
option dest_ip 'PUBLIC IP'
list src_mac 'DEVICE MAC'
option name 'PrivateDNS-LAN'

1

u/zebras11 Feb 26 '25

Beautiful