Friday, October 5, 2018

Pi-hole advertising blocking and DNS - a complete kit


I decided to build a Pi-hole to block advertisements from our home network and so I could use it as a separate DNS server from our router. I set mine up on a Raspberry Pi 3 B+ that sits headless (without monitor, keyboard or mouse) next to my router.

Detail on technology: Pi-hole and more mmm-pi-hole.
Detail on the Raspberry Pi Hardware: Raspberry Pi.

As I built this thing I discovered a few things so I thought I'd share some tips. These are not detailed directions, just a basic outline of what worked best for me. If you know your way around this kind of stuff (setting up DNS servers and home routers) it will probably be enough, but if you don't, consider finding a more detailed guide than this one! 

Here is the hardware I chose (with pricing today 2018-10-5):

Raspberry Pi 3 B+ Motherboard $40
Power Supply with switched cord $10
32GB MicroSD card and adapter $9
Flirc Aluminum case with integral heat sink $16

Total cost: $75
(You will also need a monitor with HDMI cable and a USB keyboard and mouse.)

Steps:


  1. First you need to format the SD card as FAT32.
  2. Next you need to install an operating system image on the SD Card. Raspian (Debian for the Raspberry Pi) is the obvious choice. Most of the directions recommended using "NOOBS", an installer program, but I found it set up a corrupt image on my card, and googling showed many people had problems with this. I tried the alternative method and actually found it to be much easier and I highly recommend it:
    1. Download Etcher (the image flasher)
    2. Download Raspian Stretch with Desktop (the OS)
    3. Unzip the Raspian Image
    4. User Etcher to Flash Raspian onto your SD card.
  3. Put the SD card in the Pi motherboard and connect the monitor, keyboard and mouse. Power it up!
  4. Once you have configured Raspian, you need to install the Pi-Hole software. Follow the directions on the Pi-hole website, its easy.
  5. Note, if you configure the Pi-hole initially for wifi, wlan0, it will not work over a wired Ethernet connection! You will have to go back and change the connection to your wired Ethernet port, eth0 or to "all interfaces".
  6. Configure the Pi-hole DNS as you desire. Be sure to note the password! You will need to assign it a static address on your network (see your router configuration for that) and point it at the appropriate upstream DNS servers of your choice. If you stream video services, I recommend using the servers assigned by your ISP or some other quality local server. Good article on CDNs and DNS.
  7. After power cycles, Raspian and the Pi-hole application seem to boot automatically. So you won't have to login or start the Pi-hole application manually after every reboot.
  8. If you want to operate the Pi without an attached keyboard or monitor, you can enable the VNC server built into Raspian. You can find this in the "Raspberry Pi Configuration Menu" under "Interfaces". You will need to install the VNC client on whatever device you want to use to view the server. Hard core users can enable SSH if they wish.
  9. Note you can access the Pi-hole software from any device on the local network by entering it's address in your web browser.
  10. At this point I tested the Pi-hole by telling a single computer to use it for DNS. When I was happy with how that worked I then changed the DHCP DNS settings in my router to enable the Pi-hole for the entire network.
  11. It works great!
I will note; there is not much visible improvement on a computer for the end user over something like uBlock Origin. However, the Pi-hole works great for smart phone and tablet users! And while it doesn't appear much different to computer users, it does substantially cut back on network DNS requests. The results are visible in the picture at the top of the page.

No comments:

Post a Comment