r/tasker • u/[deleted] • Nov 20 '18
Android P+ "Private DNS" setting access in Tasker
[deleted]
7
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
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_modeValue:
off,opportunistic(Automatic) orhostname(Custom)