Friday, 13 September 2019

Using the Pi-Hole with Windows

If you haven't heard of the Pi-Hole it is a great tool.  It is a DNS server (actually it is more than just that) which can run on a Raspberry Pi that simply blocks out adverts while you're browsing the web.  While some Ad-Blockers are browser add-ons this takes a different view, it simply stops the adverts from being loaded before they reach the browser.
Effectively setup the Pi-Hole on a Raspberry Pi then update the DNS settings on your Router so that it uses the Pi-Hole and then all devices connected won't see an advert as every time one is attempted to be loaded the Pi-Hole handles the request.  It's great.

But what about your laptop?  They're meant to be taken with you, so you'll see adverts when your elsewhere.

Thankfully the Pi-Hole also offer Docker images, meaning all that you require is Docker For Windows to be installed on your laptop.

So what do you need to do?
  1. Install Docker For Windows.  I'm not going to detail all of the steps but the Pi-Hole image requires a Linux container (which is handy given the size of Windows containers).  Downloading Docker For Windows requires you to create an account (or login) to Docker.
  2. Ensure that Windows containers and not the default, as to set it up we need to embrace Linux.
  3. Download the Pi-Hole image, to do this open PowerShell and run:
    Docker Pull pihole/pihole 
  4. This will take a couple of minutes (not long) to download the Linux container with the Pi-Hole installed.
  5. Create the following directories on your machine:
    • C:\pihole\
      C:\pihole\pihole
      C:\pihole\dnsmasq.d
    These are locations that the PiHole image will use to store files that will remain (for when upgrading the container to a newer version of PiHole)
  6. Run the following command to start the Pi-Hole image:
    docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80 -p 443:443 -v "c:/pihole/pihole/:/etc/pihole/" -v "c:/pihole/dnsmasq.d/:/etc/dnsmasq.d/" -e WEBPASSWORD=vRz0n36IWF --restart=unless-stopped pihole/pihole:latest
  7. I strongly suggest that you use a strong password, as the web interface to the Pi-Hole will require this to login.  You can now browse to LocalHost in a browser and you should see a page showing that the PiHole is running, although no requests are currently going to it (so it won't actually be blocking any adverts).
  8. Docker may ask you for an account to share files on your C drive (or wherever you placed them).
  9. Finally, you need to update the DNS setting for your connection to block adverts.  To do this
  10. In File Explorer right click on Network and select Properties
  11. Click on your connection
  12. Select Properties in the dialog
  13. Then select TCP/IPv4 and then properties
  14. Then set the DNS settings to be 192.168.0.1 (as the Pi-Hole container is running on your laptop).
  15. Click Ok to dismiss the dialog boxes and you're done.
  16. To see the interface for PiHole type localhost into a browser.  Click on Login and enter the password (in my example vRz0n36IWF but please change it!).  
  17. Adverts are now being blocked!