Skip to content

Instantly share code, notes, and snippets.

@sharunkumar
Created February 7, 2020 07:39
Show Gist options
  • Save sharunkumar/231edfe47380f2bce90b6f5ab9104c60 to your computer and use it in GitHub Desktop.
Save sharunkumar/231edfe47380f2bce90b6f5ab9104c60 to your computer and use it in GitHub Desktop.
Windows batch file to toggle private dns setting in android via adb
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /F %%i in ('adb shell settings get global private_dns_mode') do set dnsmode=%%i
for /F %%i in ('adb shell settings get global private_dns_specifier') do set dnshost=%%i
echo current dns setting is: !dnsmode!
if "!dnsmode!"=="hostname" (
echo current dns host is: !dnshost!
echo turning off private dns...
adb shell settings put global private_dns_mode off
echo turned off private dns setting
) else (
echo turning on private dns...
adb shell settings put global private_dns_mode hostname
echo dns set to hostname and dns host is currently !dnshost!
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment