Friday, August 14, 2020

Setting up a Pi-hole Ad blocking dns server

 Awhile back I came across this site https://pi-hole.net/   It was interesting to have a network wide ad blocker over having multiple ad blocking plugins on different browsers on different computers.  After some reading about it, I discovered it would also block ads on phones and in-app ads.  That made it more appealing since in my household we have 6 active computers, 4 phones, and 3 tablets.  To get the same kind of ad blocking I would need to install ad blockers on all the devices and even then the blocking would not be as effective as Pi-hole. It also speeds up your browsing by reducing downloaded ads and using a dns cache for frequent sites.

Pi-hole works by becoming your dns server for all the devices connected to your router.  It uses built-in ad blocking lists that can be updated and added to. After installation there is web based dashboard http://pi.hole/admin/ that shows all the addresses blocked and allows configuration of whitelists, blacklists, and all sorts of options.  During install you have the option of choosing between several free public dns servers to use as your internet dns. The choices are google, opendns, level3, comodo, dns.watch, quad9, cloudflare, or custom.  I tested a few of these and settled on quad9 for speed and consistency. It also blocks malicious sites which is nice if you have kids. After install you just need to configure your router to use your new pi-hole server for all DNS records.

First you must select the hardware you want to use.  The cheapest route is to use a raspberry pi.  I have an original raspberry pi B that met the minimum specs but I made a robot car out of it and so my choice was to use other hardware.  The sweet thing is this will run on any hardware that supports linux.  I had an intel nuc that was just collecting dust so decided to use it.  The installation was straight forward, download and install the linux distribution of your choice, it supports Ubuntu, Fedora, CentOS, Debian, and Raspberry piOS. In my case I downloaded ubuntu and used the dd command make a bootable usb stick and installed it onto my nuc. 

To install the pi-hole software, boot up your linux server and access a terminal or command prompt and type:

curl -sSL https://install.pi-hole.net | bash 

During the installation there are prompts for some information such as ip address to use for the new server and the public dns server to use.  This guide can help give more information if needed: https://www.smarthomebeginner.com/pi-hole-setup-guide/#Step_4_Pi_Hole_Installation

After install reboot your pi-hole and configure your router's dns server settings with the ip address of the pi-hole server that you assigned (i.e. 192.168.1.4) for ipv4. ipv6 can be configured with the address provided on the last installation screen.  Thats it! even though it seems complicated it literally took ten minutes once linux was installed to finish.  

The pi-hole dashboard will show when a new version of the pi-hole software is available.  To upgrade simply access your pi-hole server terminal and type: pihole -up

I've been enjoying all the stats and information on the dashboard and love to see all the blocked domains.  Enjoy!