This guide assumes you have a device running Android 8.0 (Oreo) or newer. All steps are performed without root access, using Termux – a terminal emulator that runs a minimal Linux environment on Android.
We will install dnscrypt-proxy inside Termux, configure it to use a public DNS‑over‑HTTPS (DoH) resolver, and then point Android’s network settings to the local address 127.0.0.1. The result is that every DNS request from apps and browsers will be encrypted, protecting you from ISP‑level snooping and many forms of DNS‑based attacks.
pkg update && pkg upgrade -y
This may take a few minutes as it downloads the latest repositories.
proot-distro helper (optional but useful for managing isolated Linux distributions later):
pkg install proot-distro -y
git and curl – they will be used to fetch the dnscrypt‑proxy source and configuration files:
pkg install git curl -y
dnscrypt-proxy binary from the official releases. The easiest way is to download a pre‑compiled static binary for Android (ARM64 or ARMv7 depending on your device). Determine your architecture with:
uname -m
Typical outputs:
aarch64 → ARM64armv7l → 32‑bit ARM{arch} with aarch64 or armv7 as appropriate:
curl -L -o dnscrypt-proxy.tar.gz https://github.com/DNSCrypt/dnscrypt-proxy/releases/download/2.1.5/dnscrypt-proxy-linux-{arch}.tar.gz
$PATH:
tar xzf dnscrypt-proxy.tar.gz
mv dnscrypt-proxy /data/data/com.termux/files/usr/bin/
chmod +x /data/data/com.termux/files/usr/bin/dnscrypt-proxy
dnscrypt-proxy -version
You should see the version string printed.
dnscrypt-resolvers.md file that lists many public DNS servers, including DoH endpoints. Copy the example configuration to your home directory:
cp /data/data/com.termux/files/usr/share/dnscrypt-proxy/dnscrypt-proxy.toml ~/dnscrypt-proxy.toml
nano (installed by default) or vim:
nano ~/dnscrypt-proxy.toml
listen_addresses line and set it to the loopback interface:
listen_addresses = ['127.0.0.1:53']
This tells dnscrypt‑proxy to listen on the standard DNS port (53) but only on the local device.
server_names section. Replace the default list with a DoH‑only server, for example Cloudflare’s DoH endpoint:
server_names = ['cloudflare']
require_dnssec = true
dnscrypt-proxy -config ~/dnscrypt-proxy.toml &
The ampersand runs the process in the background, returning you to the shell prompt.
dig (part of the dnsutils package) to test queries:
pkg install dnsutils -y
dig @127.0.0.1 example.com +tls
If everything works, you will see an answer section with the IP address of example.com. The +tls flag forces an encrypted query to the local proxy, which then forwards it over DoH.
ps | grep dnscrypt-proxy
termux-wake-lock and a termux-boot package that runs scripts after device boot. Install it:
pkg install termux-services termux-boot -y
~/.termux/boot directory:
mkdir -p ~/.termux/boot
cat > ~/.termux/boot/start-dnscrypt.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/sh
# Start dnscrypt-proxy with our custom config
dnscrypt-proxy -config ~/dnscrypt-proxy.toml &
EOF
chmod +x ~/.termux/boot/start-dnscrypt.sh
dig test from Step 4.127.0.0.1. Leave DNS 2 empty.https://www.cloudflare.com/cdn-cgi/trace. The page shows the ip and dns fields; the dns value should be 127.0.0.1, confirming that the device is using the local resolver.Changing the IP settings to static may break automatic IP address assignment on some networks. If you lose connectivity, simply revert the changes or re‑select “DHCP”.
dnscrypt-proxy (it appears as “Termux”). This ensures that the app can receive inbound connections on 127.0.0.1 even when the device switches from Wi‑Fi to mobile data.ps | grep dnscrypt-proxy. If not, start it manually and watch the console output for errors.listen_addresses in the TOML file to use an alternate port, such as 127.0.0.1:5353, and update the Wi‑Fi DNS entry accordingly.termux-wake-lock only when you need the resolver; otherwise, stop the process with pkill dnscrypt-proxy when you are on a trusted network.server_names (e.g., ['cloudflare','quad9']) and enable fallback_resolvers to improve reliability.blocked_names and blocked_ips. Add domains you want to force‑block (e.g., ad‑servers) to blocked_names for an on‑device ad‑blocking solution.logfile = '/data/data/com.termux/files/home/dnscrypt-proxy.log' to keep a record of queries. Useful for debugging but may expose browsing patterns – keep the file encrypted if privacy is a concern.Standard DNS queries travel in clear text, allowing anyone on the same network (public Wi‑Fi, ISP, or malicious hotspot) to see which domains you are contacting. By converting your phone into a local DoH resolver, you gain two layers of protection:
require_dnssec = true is set, the resolver validates signed records, protecting against DNS spoofing attacks.The solution runs entirely in user space, requires no rooting, and can be toggled on or off with a single command, making it suitable for privacy‑conscious users who travel frequently.
If you decide the resolver is no longer needed, you can remove it cleanly:
pkill dnscrypt-proxyrm /data/data/com.termux/files/usr/bin/dnscrypt-proxy
rm ~/dnscrypt-proxy.toml
rm ~/.termux/boot/start-dnscrypt.shYour device will return to the default DNS behavior instantly.
By following the steps above you have turned an ordinary Android phone into a privacy‑enhancing DNS‑over‑HTTPS resolver without needing root access. The approach leverages Termux’s lightweight Linux environment, the well‑maintained dnscrypt-proxy project, and Android’s native network configuration UI. You can now browse, stream, and use apps knowing that the DNS layer of your connection is encrypted and authenticated.
For users who frequently switch between networks, consider creating two Termux aliases – one that starts dnscrypt‑proxy with the default configuration, and another that stops it – to streamline the workflow.
alias startdns='dnscrypt-proxy -config ~/dnscrypt-proxy.toml &'
alias stopdns='pkill dnscrypt-proxy'









