Standard DNS queries travel in clear text, allowing anyone on the same network—Wi‑Fi routers, ISPs, or malicious hotspots—to see which domains you request. DNS‑over‑HTTPS (DoH) encrypts those queries, protecting privacy and reducing the chance of DNS‑based attacks. Running a dnscrypt‑proxy instance locally gives you full control over which DoH server you trust, without needing a rooted device.
dnscrypt‑proxy inside Termux.dnscrypt‑proxy to listen on 127.0.0.1:53 and select a trusted DoH resolver.localhost (or use a helper app on older Android).1. Open the Google Play Store, search for Termux, and install it.
2. Launch Termux. The first run will download the basic package set.
3. Update the package repository and upgrade existing packages:
pkg update && pkg upgrade -y
4. Install a few utilities that make later steps easier:
pkg install wget curl git unzip -y
Why this matters: Updating ensures you receive the latest security patches for Termux’s own tools, and the utilities are required to fetch the dnscrypt‑proxy binary and edit configuration files.
dnscrypt‑proxy is not in the default Termux repository, but the project provides pre‑compiled binaries for Android (ARM, ARM64, x86). We'll download the latest stable release.
1. Create a directory for the resolver:
mkdir -p $HOME/dnscrypt-proxy && cd $HOME/dnscrypt-proxy
2. Use wget to fetch the archive. Replace the version number with the current stable release (as of writing, 2.1.5). You can check the exact URL on the official GitHub releases page, but the pattern is consistent:
wget https://github.com/DNSCrypt/dnscrypt-proxy/releases/download/2.1.5/dnscrypt-proxy-linux-arm64-2.1.5.tar.gz
If your device is 32‑bit ARM, use the linux-arm archive instead.
3. Extract the archive:
tar xzf dnscrypt-proxy-linux-arm64-2.1.5.tar.gz --strip-components=1
4. Verify the binary is executable:
chmod +x dnscrypt-proxy
Note: The --strip-components=1 flag removes the top‑level folder inside the tarball, placing the binary directly in $HOME/dnscrypt-proxy.
1. Copy the example configuration file:
cp example-dnscrypt-proxy.toml dnscrypt-proxy.toml
2. Open the file with nano (or vim if you prefer):
nano dnscrypt-proxy.toml
3. Locate the listen_addresses line and set it to localhost on port 53:
listen_addresses = ['127.0.0.1:53']
4. Choose a DoH resolver. The file contains a # server_names = ['cloudflare', 'google'] line. Uncomment it and pick a provider you trust. For example, to use Cloudflare’s DoH endpoint:
server_names = ['cloudflare']
5. (Optional) Restrict the resolver to DNS‑over‑HTTPS only. Find the require_dnssec and require_nolog options and set them to true for extra privacy:
require_dnssec = true
require_nolog = true
6. Save the file (Ctrl+O, Enter) and exit nano (Ctrl+X).
Why these settings matter: Listening only on 127.0.0.1 prevents other apps on the device from reaching the resolver directly, which is a security best practice. Selecting a single, vetted DoH server simplifies troubleshooting and ensures you know who processes your queries.
1. Start the resolver in the foreground to see any startup errors:
./dnscrypt-proxy -config dnscrypt-proxy.toml
You should see a line like dnscrypt-proxy 2.1.5 (running) followed by a list of active servers.
2. Open a new Termux session (swipe from left edge or type termux-open) and test DNS resolution with dig (install it first if missing):
pkg install dnsutils -y
dig @127.0.0.1 example.com +short
It should return the IP address of example.com. If you see “connection timed out”, double‑check the listen_addresses line and ensure no other app is already using port 53.
What you should see: A quick response (usually within a few milliseconds) confirming the resolver is active and answering queries.
Android 9+ includes a built‑in Private DNS feature that accepts a hostname. Unfortunately, it does not accept raw IP addresses. However, you can work around this by creating a local “hostname” using the dnscrypt‑proxy built‑in DNS‑over‑TLS server on a separate port, or by using an app that allows custom DNS servers.
If you prefer not to run a local resolver, you can skip steps 2‑4 and directly set Private DNS to a trusted DoH provider (e.g., dns.cloudflare.com). This tutorial, however, demonstrates the local approach for maximum control.
Install Intra (free, no‑root). Intra can forward DNS queries to 127.0.0.1:53. After installing:
127.0.0.1 and port 53.Now Android will route DNS through your local dnscrypt‑proxy instance.
For a truly native solution on Android 9+, you can use the “Private DNS” field with a localhost hostname trick: create a tiny DNS‑over‑TLS server inside dnscrypt‑proxy that listens on 127.0.0.1:853 and then set Private DNS to localhost. This requires editing the config to enable the TLS listener:
# Add at the end of dnscrypt-proxy.toml
listen_addresses = ['127.0.0.1:53', '127.0.0.1:853']
# Enable TLS (DoT) for the second listener
tls_server_name = 'localhost'
After restarting the resolver, go to Settings → Network & internet → Private DNS → “Private DNS provider hostname” and type localhost. Android will now forward DNS over TLS to your local resolver.
Warning: Not all Android builds accept localhost as a valid hostname. If you get an error, fall back to Method B.
1. Install the “DNS over HTTPS Test” app from the Play Store (or use an online test site on the device’s browser).
2. Run the test while dnscrypt‑proxy is active. The app should report that the resolver is using DoH/DoT and display the name of the upstream server (e.g., Cloudflare).
3. For a command‑line check, capture traffic with tcpdump (installable via Termux) and look for TLS handshakes to the upstream server’s IP. The presence of TLS indicates encryption.
pkg install tcpdump -y
sudo tcpdump -i any port 443 -nn -vv
Stop the capture after a few seconds; you should see packets like TLSv1.3 Handshake heading to the DoH server.
If you want the resolver to be available after a reboot without manually launching Termux, install the Termux:Boot add‑on.
$HOME/.termux/boot (the folder is created automatically after first launch of Termux:Boot). Example script start-dnscrypt.sh:#!/data/data/com.termux/files/usr/bin/bash
cd $HOME/dnscrypt-proxy
./dnscrypt-proxy -config dnscrypt-proxy.toml &
3. Make the script executable:
chmod +x $HOME/.termux/boot/start-dnscrypt.sh
4. Reboot the device. After the boot sequence, Termux:Boot will launch the script, and dnscrypt‑proxy will be listening on 127.0.0.1:53 automatically.
Tip: Use logcat | grep dnscrypt-proxy to verify that the service started correctly.
listen_addresses to an unused port (e.g., 127.0.0.1:5353) and adjust the Private DNS/Helper app accordingly.stubby and point Private DNS to 127.0.0.1 on port 853.dnscrypt‑proxy is still running (use ps aux | grep dnscrypt). If it exited, run it again with the -config flag and check the console for error messages.dnscrypt‑proxy up to date. The project releases security patches regularly.By following these steps you have turned an ordinary Android phone into a privacy‑focused DNS client without rooting. The local dnscrypt‑proxy instance encrypts every DNS lookup, giving you visibility into which resolver you trust and the flexibility to switch providers at any time. Because everything runs inside Termux, you can easily script changes, add blocklists, or integrate the resolver into other Termux‑based networking projects.
Enjoy a safer browsing experience, and feel free to experiment with custom blocklists or alternative DoH endpoints to tailor the DNS behavior to your needs.









