Robika420 / Pi-Hole-for-WSL1

Ad-blocking DNS server for Windows 10 with DoH pre-configured. Easy setup, no hypervisor/docker required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PH4WSL1.cmd (Pi-hole for Windows)

This a script that convinces the Pi-hole installer to run on Windows 10 or Server 2019 using WSL.
Watch the installation walk-through on YouTube

Update 2021-10-23:

  • Updated to Debian 11
  • Addded shortcut for Pi-hole Updater.
  • Debian stays up-to-date using its built-in 'unattended-upgrades' mechanism.

Pi-hole on Hyper-V Server 2019 (Server Core) with 768MB RAM: Install Complete

Note: There is no endorsement or partnership between this page and Pi-hole© LLC. They deserve your support if you find this useful.

By utilizing the Windows Subsystem for Linux it is possible to run Pi-hole on a Windows 10 PC just like any other Windows app. The install script performs an automated install of Pi-hole 5.2+ on Windows 10 (version 1809 and newer) or Windows Server 2019 (including Hyper-V Core if you don't have a Windows license) - No Virtualization, Docker, or Linux expertise required. Pi-hole can be used to block ads and encrypt DNS queries on your local Windows PC or entire network.

Pi-hole for Windows is a great way to upcycle old hardware. If you have a Windows PC, tablet, or HDMI stick with 1GB RAM and it can boot Windows 10 x64 you are good to go. This installation method uses fewer resources than a hypervisor/container, and can run on older CPU's without VT support, or on a VPS without pass-through virtualization support.

INSTRUCTIONS: Copy PH4WSL1.cmd to your computer, right click the file and select "Run as Administrator."

Download and configuration steps complete in 5-20 minutes, depending on your hardware and antivirus solution. If Windows Defender is active the installation will take longer. Some users have reported issues with other antivirus products during installaion.

This script performs the following steps:

  • Enable WSL1 and download the official Debian image from salsa.debian.org

  • Download the LxRunOffline distro manager and install Debian

  • Perform gateway detection and create a /etc/pihole/setupVars.conf file for automated install

  • Run the official installer from Pi-hole©

  • Patch Pi-hole installer to use netstat.exe instead of lsof, along with other fix-ups for WSL1 compatibility.

  • Add exceptions to Windows Firewall for DNS and the Pi-hole admin page

  • NOTE: After the install completes, the Scheduled Task needs to be configured for auto-start at boot (before logon).

    • Open Windows Task Scheduler (taskschd.msc) and right-click the Pi-hole for Windows task, click edit.
    • On the General tab, place a checkmark next to both Run whether user is logged on or not and Hidden
    • On the Conditions tab, un-check the option Start the task only if the computer is on AC power

IMPORTANT! Requires August/Sept 2020 WSL update for Windows 10. This update is already included in Windows 20H2 and newer. If you don't have Windows up to date, Pi-hole installer will throw an "Unsupported OS" error midway through the installation. If this occurrs, run the Pi-hole uninstaller, update your operating system and try again. Minimum required updates are as follows:**

  • 1809 - KB4571748
  • 1909 - KB4566116
  • 2004 - KB4571756

Additional Info:

  • Rebased on Debian for a smaller footprint.

  • Integrated cloudflared DNS over HTTPS and enabled DoH in the default configuration.

  • DHCP Server is not supported and has been removed from the UI.

  • IPv6 DNS now works in addition to IPv4.

  • To reset or reconfigure Pi-Hole, run Pi-hole Configuration.cmd in the Pi-hole install folder.

  • To uninstall Pi-Hole go to the Pi-hole install folder, right-click Pi-hole Uninstall.cmd and click Run As Administrator. If you plan on reinstalling, remember to first export your configuration via the Pi-hole web interface.

Trimmed console dump and screenshots:

---------------------
 Pi-hole for Windows
--------------------- 
Set location for 'Pi-hole' install folder or hit enter for default [C:\Program Files] -> 

Pi-hole will be installed in "C:\Program Files\Pi-hole" and Web Admin will listen on port 80
Press any key to continue . . .

This will take a few minutes:  Installing Debian -> Compacting the install -> Install dependencies
Extracting templates from packages: 100%

Launching Pi-hole installer...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   145  100   145    0     0    362      0 --:--:-- --:--:-- --:--:--   364
100  121k  100  121k    0     0   100k      0  0:00:01  0:00:01 --:--:--  222k

  [✓] Root user check

        .;;,.
        .ccccc:,.
         :cccclll:.      ..,,
          :ccccclll.   ;ooodc
           'ccll:;ll .oooodc
             .;cll.;;looo:.
                 .. ','.
                .',,,,,,'.
              .',,,,,,,,,,.
            .',,,,,,,,,,,,....
          ....''',,,,,,,'.......
        .........  ....  .........
        ..........      ..........
        ..........      ..........
        .........  ....  .........
          ........,,,,,,,'......
            ....',,,,,,,,,,,,.
               .',,,,,,,,,'.
                .',,,,,,'.
                  ..'''.

  [✓] Update local cache of available packages
  [i] Existing PHP installation detected : PHP version 7.4.3
  [i] Performing unattended setup, no whiptail dialogs will be displayed

  [✗] Checking apt-get for upgraded packages
      Kernel update detected. If the install fails, please reboot and try again
  [i] Installer Dependency checks...
  [✓] Checking for dhcpcd5
  [✓] Checking for git
  [✓] Checking for iproute2
  [✓] Checking for whiptail
  [✓] Checking for dnsutils

  [✓] Supported OS detected
  [i] SELinux not detected
  [✗] Check for existing repository in /etc/.pihole
  [i] Clone https://github.com/pi-hole/pi-hole.git into /etc/.pihole...HEAD is now at 0d8ece1 Merge pull request #3889 from pi-hole/release/v5.2.1
  [✓] Clone https://github.com/pi-hole/pi-hole.git into /etc/.pihole

  [✗] Check for existing repository in /var/www/html/admin
  [i] Clone https://github.com/pi-hole/AdminLTE.git into /var/www/html/admin...HEAD is now at 8ac95be Merge pull request #1647 from pi-hole/release/v5.2.1
  [✓] Clone https://github.com/pi-hole/AdminLTE.git into /var/www/html/admin

 
  [✓] Storing downloaded domains in new gravity database
  [✓] Building tree
  [✓] Swapping databases
  [i] Number of gravity domains: 85084 (85053 unique domains)
  [i] Number of exact blacklisted domains: 0
  [i] Number of regex blacklist filters: 0
  [i] Number of exact whitelisted domains: 0
  [i] Number of regex whitelist filters: 0
  [✓] Flushing DNS cache
  [✓] Cleaning up stray matter

  [✗] DNS service is NOT listening

  [i] The install log is located at: /etc/pihole/install.log
Update Complete!

  Current Pi-hole version is v5.2.1.
  Current AdminLTE version is v5.2.1.
  Current FTL version is v5.3.2.
  [✓] DNS service is listening
     [✓] UDP (IPv4)
     [✓] TCP (IPv4)
     [✓] UDP (IPv6)
     [✓] TCP (IPv6)

  [✓] Pi-hole blocking is enabled
  [✓] Restarting DNS server

--------------------------------------------------------------------------------
Pi-hole Web Admin, Enter New Password (Blank for no password):
  [✓] Password Removed
--------------------------------------------------------------------------------
SUCCESS: The scheduled task "Pi-hole for Windows" has successfully been created.

Pi-hole for Windows installed in C:\Program Files\Pi-hole
Press any key to continue . . .

C:\>       

Installer run: PH4WSL

Install Folder:

Install Folder

Install Complete:

Install Complete

About

Ad-blocking DNS server for Windows 10 with DoH pre-configured. Easy setup, no hypervisor/docker required.


Languages

Language:Batchfile 87.5%Language:Shell 12.5%