Every time your phone queries a domain, the request travels to your ISP’s DNS resolver. That resolver often returns ads, trackers, or even malicious hosts that have been flagged by community blocklists. A DNS sinkhole intercepts those queries and returns a harmless address (usually 0.0.0.0) for any domain that matches a blocklist. The result is fewer ads, reduced data usage, and a modest privacy boost.
Running AdGuard Home on your Android device gives you a full‑featured sinkhole without needing root access. Because it runs inside Termux, the installation is portable, reversible, and works on most Android 7+ devices.
If you plan to keep the sinkhole running 24/7, consider using a cheap USB‑C power bank or a dedicated Android device that stays on all the time.
Welcome to Termux! appears.pkg update && pkg upgrade -y
pkg install wget curl tar proot -y
nano for quick file edits:
pkg install nano -y
These commands work on all Android devices that support Termux. If pkg fails, make sure you have a working internet connection and that the Play Store version of Termux is up‑to‑date.
cd $HOME
wget -O adguardhome.tar.gz https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.23/AdGuardHome_linux_arm.tar.gz
tar -xzf adguardhome.tar.gz
mv AdGuardHome $HOME/adguardhome && rm adguardhome.tar.gz
chmod +x $HOME/adguardhome/AdGuardHome
If the wget command fails with a 404, the version number in the URL has changed. Visit the GitHub releases page from a desktop, copy the latest linux_arm URL, and replace it in the command.
$HOME/adguardhome/AdGuardHome -s install
http://127.0.0.1:3000. Open Android’s Chrome (or any browser) and navigate to that address.0.0.0.0 so the server listens on all interfaces.53 (standard DNS). If another app already uses port 53, change it to an unused port like 5353 and note the number for later.http://127.0.0.1:3000/dashboard where you can see the status screen.At this point AdGuard Home is running, but your Android system is still using the ISP’s DNS. The next steps point the device to the local resolver.
Android provides two ways to set a custom DNS: the system‑wide Private DNS (DNS‑over‑TLS) and the per‑network DNS entry in the Wi‑Fi settings. Because our sinkhole works over plain DNS, we’ll use the Wi‑Fi method.
DHCP to Static.
127.0.0.1 (or localhost).:port after the address, e.g., 127.0.0.1:5353. Note that the Android UI only accepts a plain IP, so for non‑standard ports you’ll need to use the Private DNS method described below.If the Wi‑Fi network refuses the static configuration (some routers enforce DHCP only), switch to the Private DNS method instead.
After applying the settings, all DNS queries from apps on the device are sent to the AdGuard Home instance running in Termux.
http://127.0.0.1:3000/dashboard) and sign in with the admin password you set earlier.example.com (replace with any ad‑heavy site you trust).ads.google.com marked as blocked.dig +short @127.0.0.1 ad.doubleclick.net
The output should be 0.0.0.0 or an empty line, indicating the request was sinkholed.
If you still see the ads, double‑check the DNS settings in step 4 and make sure the AdGuard Home service is running (you’ll see a green “Running” badge on the dashboard).
AdGuard Home ships with a default set of blocklists, but you can improve coverage by adding community‑maintained lists.
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts – a comprehensive hosts file.https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt – AdGuard’s own curated list.Remember that each additional list consumes memory and CPU. On low‑end devices keep the total number of entries below ~150 k to avoid lag.
Termux sessions stop when you close the app or when Android kills the process to reclaim memory. To keep AdGuard Home alive you can use the termux-wake-lock and termux-notification utilities, or simply run the service in the background with nohup.
pkg install termux-api -y
cat > $HOME/start-adguard.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/bash
# Acquire a partial wake lock so the CPU stays on
termux-wake-lock
# Start AdGuard Home in the background, redirect output to a log file
$HOME/adguardhome/AdGuardHome -c $HOME/adguardhome/AdGuardHome.yaml &> $HOME/adguard.log &
# Show a persistent notification so you know it’s running
termux-notification --title "AdGuard Home" --content "DNS sinkhole is active" --button1 "Stop" --button1-action "pkill -f AdGuardHome; termux-wake-unlock; termux-notification --remove" &
EOF
chmod +x $HOME/start-adguard.sh
bash $HOME/start-adguard.sh
If your device aggressively kills background processes, enable Battery optimization → Don’t optimize for Termux.
To stop the sinkhole later, pull down the notification and tap the “Stop” button, or run pkill -f AdGuardHome from a new Termux session.
| Problem | Likely Cause | Solution |
|---|---|---|
| No DNS queries appear in the dashboard | Device still using ISP DNS | Re‑check Wi‑Fi static DNS entry; ensure you saved the changes and re‑connected. |
| AdGuard Home fails to start (error about port 53) | Another app (e.g., system DNS resolver) occupies port 53 | Change the listening port in AdGuardHome.yaml (look for bind_port) and update Android DNS settings accordingly. |
| Ads still load after adding blocklists | Blocklist format mismatch or outdated list | Verify the URL returns plain text. Use the “Update now” button and watch the log ( cat $HOME/adguard.log ) for errors. |
| Termux process killed after screen off | Battery optimization or aggressive RAM cleaning | Disable optimization for Termux (Settings → Apps → Termux → Battery → “Don’t optimize”). Enable the wake lock script as shown in Step 7. |
Cannot access http://127.0.0.1:3000 from Chrome | AdGuard Home not running or firewall blocking loopback | Run ps aux | grep AdGuardHome to confirm. If missing, start it with $HOME/adguardhome/AdGuardHome -c $HOME/adguardhome/AdGuardHome.yaml. |
If your Wi‑Fi network forces DHCP DNS and you cannot set a static address, Android’s Private DNS feature can forward encrypted DNS to a local DoH endpoint. AdGuard Home supports DoH out of the box.
sed -i 's/^#\s*doH:/doH:/; s/^#\s*doH_port:/doH_port:/' $HOME/adguardhome/AdGuardHome.yaml
This uncomment lines and sets the default DoH port (443).
pkill -f AdGuardHome && $HOME/adguardhome/AdGuardHome -c $HOME/adguardhome/AdGuardHome.yaml &
127.0.0.1 (Android accepts an IP as a hostname for DoH).https://dns.google/resolve?name=example.com – you should get a JSON response from your local DoH server.
Note: Not all Android skins allow an IP address in the Private DNS field. If you encounter a validation error, you can create a local hostname by editing /etc/hosts via Termux (requires root) or use the Wi‑Fi static method instead.
If you decide the sinkhole is no longer needed, removal is straightforward:
pkill -f AdGuardHomerm -rf $HOME/adguardhomeAll your personal data remains on the device; AdGuard Home does not store any user‑identifying information unless you enable the optional statistics feature.
By following this tutorial you have turned an ordinary Android phone into a lightweight, local DNS sinkhole that blocks ads, trackers, and known malicious domains without requiring root access. The approach is portable – you can copy the adguardhome folder to another device, run the same script, and be up and running in minutes.
Remember to keep your blocklists refreshed (AdGuard Home can auto‑update them daily) and to monitor the service if you notice any connectivity hiccups. With the optional wake‑lock script, the sinkhole can stay active even when the screen is off, giving you continuous protection on the go.









