Pihole on a raspberry pi – making a network wide advert blocker with a raspberry pi.
I have a router using dnsmasq with adblocking setup on my router.
I also have a raspberry pi (which was being used as a retropi machine). I also have a Pizero. My retropi setup is moved to my pizero, leaving my PI with nothing to do.
PiHole sounds like an awesome little project, so this post is a Sunday afternoon spent turning my PI into a network wide advert blocker using piHole (and doing the setup from a mac.)
1) Download raspian and install it onto an SD card – install instructions are here:
Basically it goes:
- insert SD card
- open disk utility
- format SD card as MS_DOS (FAT)
- find what disk your SD card is identified as
- diskutil list
- unmount SD card (but keep it plugged in)
- diskutil unmountDisk /dev/disk2
- open terminal
- write image to SD card
- sudo dd bs=1m if=raspbian-jessie-lite.img of=/dev/disk2
- eject SD card
- plug SD card into pi
- boot pi
2) Enable SSH on boot
- advanced > ssh
3) Set a static IP address
This used to be in /etc/network.interfaces
Now its in /etc/dhcpd.conf
Pihole on a raspberry pi
4) Download pihole (https://pi-hole.net)
curl -L https://install.pi-hole.net | bash
Run through the install and configure your pi to use a static IP address
5) Log in to your router and change your main DNS server to the static IP address of your pi
Thats it – all machines on your network are now using your Pihole on a raspberry pi as their dns and adverts are being blocked!