[DEV][ROOT] Pi-hole for Android // Deploy Pi-hole DNS server to ANY Android 4.x device.

Search This thread

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
Pi-hole for ARMv7 (2011 and newer) Android devices.

[ Preface: I have successfully deployed this to several ARMv7 and ARMv8 devices, but looking for additional test devices to ensure the scripts are robust enough to detect the many various device configurations out there, especially interested in RockChip and Allwinner-based Android HDMI sticks. Please give it a spin and report your results - Thanks! ]

1631494815749.jpeg


Pi-hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole intended for use on a private network. It is designed for low-power embedded devices with network capability, most well-known being the Raspberry Pi.

This customized Linux Deploy image works on any rooted Android device with an ARMv7 (or newer) class CPU. This typically includes anything made in the past 10 years. Form factor is not important; it could be a phone, tablet, HDMI stick or any device running Android.

Requirements:


· Android device, rooted
·
Developer Options -> Root Access -> Enabled for Apps

Instructions:

· Open browser on device and download+install the Linux Deploy APK below. You can also download it from the Play Store if you prefer:

· Download the Pi-hole for Android disk image: (v1.5 / January 16, 2022)

· http://desktopecho.com/p4a15.tar.gz (MD5: f20ce97741a56fc599739bf830f53be9)​

· Restart Phone (This is REQUIRED)

· Open Linux Deploy

· Open Properties Menu (Bottom Right)​
· Distribution: rootfs.tar​
· Source Path - This varies depending on the device, ie: ${EXTERNAL_STORAGE}/Download/p4a15.tar.gz​
· Set password for user "android"​
· Init -> Enable​

· Go back to main window, click Options Menu (Three dots, top right of screen) and click "Install"

· Wait a few minutes for the disk image to install.​
· Allow the install to complete before proceeding to next steps.​
· When install is complete, the Linux Deploy console window will show the following:​

Code:
[HH:mm:ss] >>> :: Configuring core/launchroot ...
[HH:mm:ss] >>> deploy

· Open Hamburger Menu (Top Left) and touch "Settings"

· Place check mark on Lock Wi-Fi
· Place check mark on Autostart

Touch the [ -> START ] button and confirm when prompted.

Pi-hole is now installed and running!

Your Android device's IP is shown at the top of the Linux Deploy main window. You can interact with the Pi-hole instance in three ways:

Open a web browser to the Android device's IP address. Example:
http://10.13.12.11/admin

SSH to the instance on port 22. Example:
ssh [email protected]

RDP to the device's IP address to open an XTerm. Example:
mstsc.exe /v:10.13.12.11

Additional Info

You can restart (or "bounce") the Pi-hole instance in Linux Deploy by pressing [ ■ STOP ] and waiting a few seconds for the instance to indicate all services are stopped. Restart the instance by pressing [ ▸ START ]

When a Pi-hole instance starts up, the default setting is to let it automagically configure networking. If you change networks on the Android device simply restart the instance for Pi-hole to pick up the new settings.

Alternatively, set a static assignment by commenting-out two lines in /etc/rc.local (You will see which ones when you open the file in an editor.) After the lines are commented out with a hash "#" you can manually add your IP, subnet and interface name to /etc/pihole/setupVars.conf

The Pi-hole instance on Android otherwise behaves like it is running on a 'real' Raspberry-Pi or a standard PC. Consult the extensive documentation online to learn how to fully leverage Pi-hole's functionality.

Adjust QT display scaling: ~/startwm.sh

Change the font size in QTerminal: ~/.config/qterminal.org/qterminal.ini

If your Android device has a battery and was unused for months or years, replace its battery.
Old, worn, or abused Li-ion batteries can fail when pushed back into service. Failure appears as a bulge in the battery, "thermal event" or worse. A new battery makes an excellent UPS for the tiny Linux box you just provisioned!
 
Last edited:

ashishkotnala29

Senior Member
Nov 27, 2011
424
353
New Delhi
Thanks a lot for this, I find this the only working solution for Pi-hole + unbound on Linux Deploy. I was able to run pi-hole from scratch on debian/ubuntu based images but was not able to get unbound running and not sure why it always gave SERVFAIL.

Anyways, this worked I wonder why...

On a separate note I tried updating pi-hole but it only updated FTL version to v5.13 and I know the core and web-interface is also updated and newer versions are released but for some reason pihole shows it's up to date in the "pihole -up" command BUT it shows update available on web interface (admin panel).
Can you let me know why?
 

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
What model phone do you have?

CentOS 7 Was the only distro I could convince to work on every android phone. Android 4.x shipped with a 3.0 kernel and CentOS has a glibc juuuust old enough to be able to run with a kernel that old.

Yesterday I released version 1.5 which should take care of the update issue. Give that a shot and let me know how things look for you.
 
  • Like
Reactions: ashishkotnala29

ashishkotnala29

Senior Member
Nov 27, 2011
424
353
New Delhi
I dug into this more seems like this PR merge causes it: https://github.com/pi-hole/pi-hole/pull/4475
I reverted the changes to that script and it worked. I made a comment on that PR, hopefully they'll fix.

Thanks for the update, I'll check it now.

I use Xiaomi Redmi Note 4G (codename: dior). Using my own self-built LineageOS 14.1 (Kernel 3.4.0). I understand the issues with having older kernel version with newer distributions and yes, you're right CentOS 7 would be perfect for this use case. Unfortunately pihole install script by default didn't support CentOS 7 on ARM so I didn't go that way initially.

Also, Is there a way I could check for newer versions of your container other than XDA?
 
Last edited:

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
Hi Ashish, The 'official' page is located on GitHib:
https://github.com/DesktopECHO/Pi-hole-for-Android

Nice find with the git versioning issue! You can also just run ``p4a-install`` which does the same thing but skips the version check and force-installs the latest Pi-hole release. I think they will fix this... fyi the Pi-hole installer works on CentOS ARMv7, that may not have been the case a year or two ago. In any case if you're on Kernel 3.4 you should be able to get a modern distro running without too much grief. The project page on GitHub has all my fix-ups, you should be able to apply them against your preferred Linux flavour.
 
  • Like
Reactions: ashishkotnala29

mrbox23

Senior Member
Mar 22, 2010
582
90
Colorado Springs
Few hours later...
Stopped for some reason...


Screenshot_20220121-014802261.jpg
 

Attachments

  • Screenshot_20220121-021655643.jpg
    Screenshot_20220121-021655643.jpg
    401.3 KB · Views: 34
  • Screenshot_20220121-021521885.jpg
    Screenshot_20220121-021521885.jpg
    292.5 KB · Views: 34
  • Screenshot_20220121-021538491.jpg
    Screenshot_20220121-021538491.jpg
    135.8 KB · Views: 40
  • Screenshot_20220121-021721484.jpg
    Screenshot_20220121-021721484.jpg
    438.9 KB · Views: 45
Last edited:

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
Hi there, I'm pretty sure the disk resize had something to do with your issue -- I see "pihole -up" was complaining there was no disk space left.

For what it's worth, my Galaxy S2 has been running Pi-hole months at a time without issues.
 

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
One more thing, just an FYI if you're interested... as of P4A update v1.5 you can tell Linux Deploy to install to a folder on your Android device instead of a disk image. That way you don't have to worry about filling up the image file.
 

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda

ashishkotnala29

Senior Member
Nov 27, 2011
424
353
New Delhi
Had to figure out the dependencies and I only installed 4 packages out of all those and I think it is working... The results are promising.

1642851470620.png


This test is on your v1.4 image because it makes sense there. Using old git 1.8.x we only got FTL update here.

Finally going through the update and it was a success!

1642851570999.png


Thanks a lot for compiling these RPMs.

Here's are the prerequisites which are needed to install the RPMs you complied.

Bash:
sudo yum remove -y git
sudo yum clean all
sudo yum install -y emacs-filesystem pcre2

Then only install git, git-core, git-core-doc and perl-Git. That's all!
 
Last edited:
  • Like
Reactions: DesktopECHO

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
We managed to figure out the issue. It was the "git fetch --tags origin" command on v1.8.x. For some reason this doesn't work the same as in modern git versions.

Discussion here: https://github.com/pi-hole/pi-hole/pull/4475
Fix here: https://github.com/pi-hole/pi-hole/pull/4575

Thanks for your help!
You’re welcome! And thank you for chasing down that bug.

They had a similar issue with bash on CentOS 7 a few months ago. Next re-spin of P4A I think I’ll just include the updated Git just for a little extra insurance. Will also be switching to OpenSSH from DropBear (so Gravity Sync can work) now that I have sorted out why it wouldn’t start.
 
  • Like
Reactions: ashishkotnala29

ashishkotnala29

Senior Member
Nov 27, 2011
424
353
New Delhi
Hey @DesktopECHO I have a small issue idk who to ask maybe you've come across this in your testing.
I have a very old Chinese android tablet running Android v4.1.1 on kernel v3.0.8. It has 2 cores Cortex-A9.

Everything seems to work fine but as soon as I turn the screen off the detected core count reduces to 1. It's like 1 core is put to sleep and is no longer "visible" to the OS. I've verified this using the "htop" utility and on pi-hole web-ui (hover over green/red status beside load averages).

I am using wake lock apps to keep the Wifi performance high. I also tried changing CPU governor to ondemand/interactive/performance still same behavior. Any ideas how can I keep both cores online while keeping screen off?

EDIT: Seems to be working fine when switched to ondemand governor and restarting.
 
Last edited:

DesktopECHO

Member
Sep 10, 2021
14
16
Hamilton, Bermuda
Sometimes the closest you can get is to just turn down the screen brightness to zero which should be 'good enough' for most situations, we just need to find where that control is on your device.

Break out of chroot:

Code:
[[email protected] ~]$ unchroot

Find a hint for where screen brightness is controlled:

Code:
localhost:(unreachable) # find /sys/ -name brightness

For my device I get:

Code:
/sys/devices/platform/soc/1a00000.qcom,mdss_mdp/1a00000.qcom,mdss_mdp:qcom,mdss_fb_primary/leds/lcd-backlight/brightness
/sys/devices/platform/soc/78b5000.i2c/i2c-1/1-005a/leds/vibrator/brightness
/sys/devices/platform/soc/7864900.sdhci/leds/mmc1::/brightness
/sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-03/200f000.qcom,spmi:qcom,[email protected]:qcom,[email protected]/leds/charging/brightness
/sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-03/200f000.qcom,spmi:qcom,[email protected]:qcom,[email protected]/leds/green/brightness
/sys/devices/platform/soc/200f000.qcom,spmi/spmi-0/spmi0-03/200f000.qcom,spmi:qcom,[email protected]:qcom,[email protected]/leds/blue/brightness

In my case it was the first entry, so to confirm we'll try turning down the brightness:

Code:
echo 0 > /sys/devices/platform/soc/1a00000.qcom,mdss_mdp/1a00000.qcom,mdss_mdp:qcom,mdss_fb_primary/leds/lcd-backlight/brightness

It worked! Sometimes you have to try 1 instead of 0 as the minimum value. Usually it's 0-255
 
  • Like
Reactions: ashishkotnala29

ashishkotnala29

Senior Member
Nov 27, 2011
424
353
New Delhi
Sometimes the closest you can get is to just turn down the screen brightness to zero which should be 'good enough' for most situations, we just need to find where that control is on your device.

It worked! Sometimes you have to try 1 instead of 0 as the minimum value. Usually it's 0-255
Thanks for this. Yeah I was aware that keeping screen on will let me achieve my goal but I was trying to avoid it unless absolutely necessary.

I've been using this app for keeping wake locks since for some reason the CPU and Wifi lock options in Linux Deploy app do not work for me on the two devices that I tested. "Partial wake lock" option in this app works great, keeps wifi up and CPU too while screen off.
 

savvyyy

Member
Jan 2, 2020
34
5
I've googled something like this a month ago, it's like you guessed. Thank you so much @DesktopECHO !!

This is probably a very silly question but give me some leeway.
If I'm browsing the web on the android device where my pihole is deployed, shouldn't it be blocking ads as I'm browsing ?
 
  • Like
Reactions: DesktopECHO

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    Pi-hole for ARMv7 (2011 and newer) Android devices.

    [ Preface: I have successfully deployed this to several ARMv7 and ARMv8 devices, but looking for additional test devices to ensure the scripts are robust enough to detect the many various device configurations out there, especially interested in RockChip and Allwinner-based Android HDMI sticks. Please give it a spin and report your results - Thanks! ]

    1631494815749.jpeg


    Pi-hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole intended for use on a private network. It is designed for low-power embedded devices with network capability, most well-known being the Raspberry Pi.

    This customized Linux Deploy image works on any rooted Android device with an ARMv7 (or newer) class CPU. This typically includes anything made in the past 10 years. Form factor is not important; it could be a phone, tablet, HDMI stick or any device running Android.

    Requirements:


    · Android device, rooted
    ·
    Developer Options -> Root Access -> Enabled for Apps

    Instructions:

    · Open browser on device and download+install the Linux Deploy APK below. You can also download it from the Play Store if you prefer:

    · Download the Pi-hole for Android disk image: (v1.5 / January 16, 2022)

    · http://desktopecho.com/p4a15.tar.gz (MD5: f20ce97741a56fc599739bf830f53be9)​

    · Restart Phone (This is REQUIRED)

    · Open Linux Deploy

    · Open Properties Menu (Bottom Right)​
    · Distribution: rootfs.tar​
    · Source Path - This varies depending on the device, ie: ${EXTERNAL_STORAGE}/Download/p4a15.tar.gz​
    · Set password for user "android"​
    · Init -> Enable​

    · Go back to main window, click Options Menu (Three dots, top right of screen) and click "Install"

    · Wait a few minutes for the disk image to install.​
    · Allow the install to complete before proceeding to next steps.​
    · When install is complete, the Linux Deploy console window will show the following:​

    Code:
    [HH:mm:ss] >>> :: Configuring core/launchroot ...
    [HH:mm:ss] >>> deploy

    · Open Hamburger Menu (Top Left) and touch "Settings"

    · Place check mark on Lock Wi-Fi
    · Place check mark on Autostart

    Touch the [ -> START ] button and confirm when prompted.

    Pi-hole is now installed and running!

    Your Android device's IP is shown at the top of the Linux Deploy main window. You can interact with the Pi-hole instance in three ways:

    Open a web browser to the Android device's IP address. Example:
    http://10.13.12.11/admin

    SSH to the instance on port 22. Example:
    ssh [email protected]

    RDP to the device's IP address to open an XTerm. Example:
    mstsc.exe /v:10.13.12.11

    Additional Info

    You can restart (or "bounce") the Pi-hole instance in Linux Deploy by pressing [ ■ STOP ] and waiting a few seconds for the instance to indicate all services are stopped. Restart the instance by pressing [ ▸ START ]

    When a Pi-hole instance starts up, the default setting is to let it automagically configure networking. If you change networks on the Android device simply restart the instance for Pi-hole to pick up the new settings.

    Alternatively, set a static assignment by commenting-out two lines in /etc/rc.local (You will see which ones when you open the file in an editor.) After the lines are commented out with a hash "#" you can manually add your IP, subnet and interface name to /etc/pihole/setupVars.conf

    The Pi-hole instance on Android otherwise behaves like it is running on a 'real' Raspberry-Pi or a standard PC. Consult the extensive documentation online to learn how to fully leverage Pi-hole's functionality.

    Adjust QT display scaling: ~/startwm.sh

    Change the font size in QTerminal: ~/.config/qterminal.org/qterminal.ini

    If your Android device has a battery and was unused for months or years, replace its battery.
    Old, worn, or abused Li-ion batteries can fail when pushed back into service. Failure appears as a bulge in the battery, "thermal event" or worse. A new battery makes an excellent UPS for the tiny Linux box you just provisioned!
    1
    What model phone do you have?

    CentOS 7 Was the only distro I could convince to work on every android phone. Android 4.x shipped with a 3.0 kernel and CentOS has a glibc juuuust old enough to be able to run with a kernel that old.

    Yesterday I released version 1.5 which should take care of the update issue. Give that a shot and let me know how things look for you.
    1
    Hi Ashish, The 'official' page is located on GitHib:
    https://github.com/DesktopECHO/Pi-hole-for-Android

    Nice find with the git versioning issue! You can also just run ``p4a-install`` which does the same thing but skips the version check and force-installs the latest Pi-hole release. I think they will fix this... fyi the Pi-hole installer works on CentOS ARMv7, that may not have been the case a year or two ago. In any case if you're on Kernel 3.4 you should be able to get a modern distro running without too much grief. The project page on GitHub has all my fix-ups, you should be able to apply them against your preferred Linux flavour.
    1
    Very nice! Running on OnePlus Nord N10 here. arm64-v8a
    1
    Going again, nothing is logged, however it seems to function well and good.