Many Android users want every app and website to use encrypted DNS (DoH/DoT) but don’t want to rely on a third‑party app that may request extra permissions. By running dnscrypt‑proxy inside Termux you can create a local DNS‑over‑HTTPS resolver that listens on 127.0.0.1:53. Android’s built‑in Private DNS feature can then point to this local address, giving you system‑wide DNS encryption without rooting or installing any UI‑heavy apps.
yes when prompted.pkg update && pkg upgrade -y
This may take a few minutes.dnscrypt‑proxy depends on a few utilities. Install them with a single command:
pkg install -y dnscrypt-proxy curl jq
If dnscrypt-proxy is not found in the default repository (some Termux releases), you can install it from the unstable-repo:
pkg install -y unstable-repo
pkg install -y dnscrypt-proxy
dnscrypt‑proxy ships with a list of public resolvers. We’ll pick a DoH‑only server for maximum privacy. The list is stored in /data/data/com.termux/files/usr/etc/dnscrypt-proxy.
cd $PREFIX/etc/dnscrypt-proxy
nano (or vim if you prefer):
nano dnscrypt-resolvers.md
type: "doh". Example entries:
- name: cloudflare-dns.com
stamp: "sdns://..."
dnssec: true
doH: true
description: "Cloudflare DNS over HTTPS"
cloudflare-dns.com or dns.google). Remember the name value – you’ll need it in the next step.By default dnscrypt‑proxy may bind to all interfaces, which could expose the resolver to other devices on the network. We’ll restrict it to 127.0.0.1 and port 53 (the standard DNS port).
nano dnscrypt-proxy.toml
listen_addresses line. If it’s commented out, uncomment and set it to:
listen_addresses = ['127.0.0.1:53']
server_names array. Replace the default value with the name you chose in Step 3, e.g.:
server_names = ['cloudflare-dns.com']
dnscrypt-proxy -config $PREFIX/etc/dnscrypt-proxy/dnscrypt-proxy.toml
You should see a line similar to:
dnscrypt-proxy[12345]: listening on 127.0.0.1:53 (UDP/TCP)
dig (install it if missing):
pkg install -y dnsutils
dig @127.0.0.1 example.com +short
You should receive the IP address of example.com. If you get connection timed out, double‑check the listen_addresses setting and ensure no other app is already using port 53.cat > $HOME/start-dnscrypt.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/bash
nohup dnscrypt-proxy -config $PREFIX/etc/dnscrypt-proxy/dnscrypt-proxy.toml &>/dev/null &
EOF
chmod +x $HOME/start-dnscrypt.sh
Run it:
~/start-dnscrypt.sh
The resolver now runs silently in the background.
Android’s Private DNS feature expects a hostname that resolves to a DoT/DoH server. However, it also accepts localhost when you manually edit the system DNS settings via Wi‑Fi. We’ll use the Wi‑Fi advanced settings to force DNS to 127.0.0.1.
Static. (Don’t worry – you’ll keep the original IP address; we’re only changing DNS.)127.0.0.1. Leave the rest of the network configuration untouched.If you switch between Wi‑Fi networks frequently, you’ll need to repeat this step for each network. Alternatively, you can use a VPN‑style app that forces DNS to a specific address, but that would add a third‑party component.
To confirm that Android is really using your local DoH resolver, perform a DNS‑leak test.
dig again, but this time without specifying an address. The query will travel through Android’s DNS stack to your local resolver:
dig example.com +short
The answer should match the earlier test.
Termux sessions disappear when the device restarts. To automate the start‑up, use Termux’s boot add‑on.
~/.termux/boot directory if it doesn’t exist:
mkdir -p ~/.termux/boot
cp $HOME/start-dnscrypt.sh ~/.termux/boot/
ps | grep dnscrypt-proxy to confirm the process is running.
If you prefer DNS‑over‑TLS (DoT) because your chosen provider only offers it, you can still use dnscrypt‑proxy. The configuration steps are identical; just pick a resolver with type: "dot" in the dnscrypt-resolvers.md file. The rest of the workflow stays the same.
address already in use, change the listen port in dnscrypt-proxy.toml to 5353 and update the Wi‑Fi DNS entries accordingly.
READ_PHONE_STATE permission (Settings → Apps → Termux:Boot → Permissions). Without it, the boot script may be killed.
VpnService to tunnel DNS elsewhere. Most apps use the system resolver, which is now encrypted.dnscrypt‑proxy up to date (run pkg upgrade dnscrypt-proxy periodically) to receive security patches and updated resolver lists.By following these steps you have turned an ordinary Android phone into a self‑contained DNS‑over‑HTTPS gateway. The solution respects the No Root constraint, avoids third‑party apps with opaque permissions, and gives you full control over which DNS provider encrypts your queries. If you ever need to switch providers, just edit dnscrypt-proxy.toml and restart the script – the rest of the system stays untouched.
Enjoy a more private browsing experience on Android, and feel free to experiment with other dnscrypt‑proxy features such as blocking known malicious domains or enabling DNSSEC validation.









