Network-wide ad-blocker – it’s possible with Pi-hole

Can you imagine? No ads on your phone, on your tablet – even in the free apps and on YouTube? Pi-hole can help you achieve this in your home or office network and even on the go.

What is Pi-hole?

Pi-hole is the DNS server which is working in your network. Instead of asking your provider DNS server hat IP should be used to see given domain, your devices will ask Pi-hole. Because most of the ads are served from particular domains,  Pi-hole is able to block such requests. This way you can achieve ad-free environment on all devices connected to your home or office network. As you will see later – it is possible to achieve this effect also on the go, but first things first.

What will I need?

In order to install Pin-hole, you have to have a device which is able to run Linux. The easy way is to obtain Raspberry Pi – this is why the name of the solution is “Pi”-hole – it was meant to run on this microcomputer. The fact is that any Linux server should be good. I installed it on various Ubuntu and Raspbian based devices. It is good if given device has regular Ethernet port instead of WiFi connectivity – answer times are shorter.

You can also install this solution on the Virtual Private Server in Digital Ocean or AWS – wherever you want. Such installation will help you on the go.

Installation

The installation process is really simple. You should be login to your Linux as root and you can simply run this command:

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

Please note that this will execute the script which is taken from the web. You can download and review it first. The script is taking care of all aspects of the installation – installs required packages, handles firewall configuration, DNS service and web administration service. Once Pi-hole is installed you are ready to use it. One additional useful information is: you can change pi-hole web interface password only from the command line right now. The command to do this is:

pihole -a -p

Configuration

Your new DNS is now ready to use. You have two possibilities now: you can change your DNS address on each device you will use or you can change the configuration of your router. DNS adjustment on the device gives you complete control over the usage of our new DNS. You will be able to turn it on and off whenever you want for given device. On the other hand – you will have to take care of the configuration of each device separately. This can take a lot of time. If you simply want all your devices to use it, you should configure your router to use DNS you just configured. You probably have the IP of the server you just installed pi-hole on, so you can simply adjust your router configuration to use only this IP as DNS server. If there is DNS configuration also stored in your DHCP server, you can adjust DNS also there. Please note that in most cases you will have to wait or renew your IP lease in order to make it work – your computers remember “old” DNS configuration for some time.

Pi-hole on the go

You may ask – what should I do if I want to have this protection always? You probably heard about VPN. This is why I wrote that you can install pi-hole on the remote server, VPS located somewhere on the Internet. Once you will have your DNS prepared, you can install also VPN solution such as OpenVPN. This will give you an ability to connect to your server from any place in the world. This will also give you an extra layer of security. VPN can protect your data when you are using WiFi in places such as airports, hotels or cafes. You can kill two birds with one stone.

Drawbacks

You should know that there are also drawbacks to using this solution. From time to time I need to handle Adwords campaign or review Analytics data. Domains of these services are blocked by default. If you will notice such issue you can simply change DNS address on given device for a while. This will give you an access to the domain you want. The other way is to whitelist given domain in the Pi-hole configuration. Please note that this way you will give an access to this domain for all devices.