Pi Hole is an ad blocking service that uses your server as a DNS to filter out known ad sites and can even filter out pornographic and malicious sites.
Let's update and upgrade our packages.
sudo apt-get update && sudo apt-get upgrade -y
We will need to install git in order to download the Pi Hole repository.
sudo apt-get install git
Because your internal IP address can change, we will need to give it a static address.
sudo vim /etc/network/interfaces
If you have any of the following text...
iface eth0 inet dhcp
Replace it with the following...
iface eth0 inet static
dns-nameservers 22.214.171.124 126.96.36.199
The dns-nameservers could change if you decide not to go with Google. Save the file and reboot your server.
Let's get Pi Hole now.
If you want to install it using curl.
curl -sSL https://install.pi-hole.net | bash
Or install it with Git.
git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd Pi-hole/automated\ install/
Follow the setup guide. Choose your DNS provider. Choose wether or not you want a Web Interface (Recommended). Logging should be enabled if you are using a Web Interface. Hit Yes, to add firewall rules to allow TCP port 80 and TCP and UDP port 53. You'll want to take note of your Web Interface Password near the end of the installation as it will ask for it when you try logging into the web interface.
If you have UFW firewall enabled, you'll need to open the open TCP port 80 for the web interface and TCP and UDP port 53 required by DNS.
sudo ufw allow http
sudo ufw allow 53
Now you will need to enter into your router's interface and change the DNS server to be the static ip you chose, in my case it was 192.168.1.15.
You can open Pi Hole's web interface by using the following url.
You will want to go to your router's login page and add your Pi Hole as the DNS server. If this step isn't done, the internet request will not be routed through your server. You'll want to look up how to do so in accordance to the model of router you have.
If you change your mind after using your first DNS choice, here is a list of other providers and what they offer.
Tracking & Telemetry Lists